---
import std.algorithm;
import std.range;
import std.stdio;
void main(){
only(iota(0,4),[1,4,5]).writeln;
}
---
How can I call std.range.only with different range types?
Is there a version of
http://dlang.org/phobos/std_range.html#.generate with state.
On Tuesday, 3 November 2015 at 00:08:54 UTC, Ali Çehreli wrote:
generate() already allows "callables", which can be a delegate:
import std.stdio;
import std.range;
struct S {
int i;
int fun() {
return i++;
}
}
void main() {
auto s = S(42);
writefln("%(%s %)",
Is there any way I can Unionize range Types?
---
auto primeFactors(T)(T t, T div = 2)
{
if (t % div == 0)
{
return t.only.chain(primeFactors(t / div, div));
}
if (div > t)
{
return [];
}
else
{
return primeFactors(t, div + 1);
}
}
---
On Friday, 30 October 2015 at 10:35:03 UTC, Laeeth Isharc wrote:
I'm writing a talk for codemesh on the use of D in finance.
I want to start by addressing the good reasons not to use D.
(We all know what the bad ones are). I don't want to get into
a discussion here on them, but just wanted
On Sunday, 18 October 2015 at 17:58:30 UTC, Meta wrote:
Is this a simplified use case of some actual code you have?
Otherwise, you can just do:
bool iden(string str)
{
auto f = str.front;
return f.isAlpha || f == '_';
}
It's simplified, i wanted to check for empty
How do you call startsWith with only a predicate
---
import std.algorithm;
import std.ascii;
bool iden(string str)
{
return str.startsWith!(a => a.isAlpha || a == '_');
}
---
There are two these different ways to pass functions as template
arguments. Which is preferred?
---
void funcA(alias calle)()
{
calle();
}
void funcB(T)(T calle)
{
calle();
}
void main()
{
funcA!(() => 0);
funcB(() => 0);
}
---
How do I use http://dlang.org/phobos/std_range_interfaces.html in
pure @safe code?
Is there a way to make a range of a variables lazily?
---
int var1;
int var2;
void func()
{
int var3;
auto range = /*range of var1,var2,var3*/ ;
}
---
How do you take the address of a specific overloaded function.
This won't compile
---
import std.range;
void main()
{
ForwardAssignable!int range;
int delegate() @property get =
void delegate(int) @property set =
}
---
What does it mean when there is a scope in a function argument.
---
void func(scope int* a){}
---
dmd's source code is very big, are there tips for reading
it(important files)?
I can't get pragma(mangle) to work on templates(or structs).
import std.stdio;
struct MyStruct(T...)
{
int var;
void func()
{
writeln(var);
}
}
pragma(mangle, MyAlias) alias MyAlias = MyStruct!(a, b, c
/+very long symbol bloating list+/ );
void main()
{
auto
On Monday, 17 August 2015 at 02:45:22 UTC, Brandon Ragland wrote:
if(file[(*pos + i)] == '}'){
*pos += i;
return;
}
That code doesn't do what you want it do. file is a ((char[])*)
you are indexing the pointer(accessing invalid memory) and
getting a char[].
On Monday, 17 August 2015 at 03:14:16 UTC, Adam D. Ruppe wrote:
On Monday, 17 August 2015 at 02:46:02 UTC, Freddy wrote:
Mangling is done at a different level in the compiler than
aliases, so I don't think this is intended to work.
Is there any way I can mangle a template struct then?
I have a file that takes a while to compile with a static
interface. Is there any way i can make dub keep the object file
of only that file(for faster compilation)?
std.traits has ImplicitConversionTargets.
Is there any template that returns the types that can implicty
convert to T?
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can only create structs, dynamic arrays or
class objects, not int[string]'s
Failed: [dmd, -v, -o-, test.d, -I.]
On Tuesday, 19 May 2015 at 00:00:30 UTC, Meta wrote:
On Monday, 18 May 2015 at 23:55:40 UTC, Freddy wrote:
How do you allocate an associative array on the heap?
void main(){
alias A=int[string];
auto b=new A;
}
$ rdmd test
test.d(4): Error: new can only create structs,
On Monday, 20 April 2015 at 02:56:35 UTC, Ali Çehreli wrote:
Not automatically. Check out addRange and addRoot:
http://dlang.org/phobos/core_memory.html
Ali
The destructor doesn't seem to be running
import std.stdio;
import std.c.stdlib;
import core.memory;
struct Test{
On Monday, 20 April 2015 at 22:24:53 UTC, Ali Çehreli wrote:
On 04/20/2015 02:48 PM, Freddy wrote:
On Monday, 20 April 2015 at 02:56:35 UTC, Ali Çehreli wrote:
Not automatically. Check out addRange and addRoot:
http://dlang.org/phobos/core_memory.html
Ali
The destructor doesn't seem to be
C libraries have a pattern of
HiddenType* getObj();
void freeObj(HiddenType*);
Is there any way I can make the GC search for a HiddenType* and
run freeObj when the pointer is not found.
Is there any way to do a final switch statement in std.variant's
Algebraic.
Why are strings immutable but array literals are not?
import std.stdio;
auto test1(){
void testFunc(){
}
return testFunc;
}
auto test2(){
uint a;
void testFunc(){
a=1;
}
return testFunc;
}
void main(){
writeln(test1()==test1());//true
import std.stdio;
@safe:
void main()
{
writeln(Edit source/app.d to start your project.);
}
source/app.d(5): Error: safe function 'D main' cannot call system
function 'std.stdio.writeln!(string).writeln'
I know what this does, but can someone explain how it works?
static if((typeof((inout int=0){
})));
On Tuesday, 11 November 2014 at 19:23:39 UTC, Adam Taylor wrote:
* i apologize in advance, this is my first post -- the code
formatting probably wont turn out so great...
I have a bunch of duck typed interfaces for containers
similar to what you would find in std.range.
i.e.
template
On Wednesday, 22 October 2014 at 20:29:58 UTC, Cjkp wrote:
Hello, I have an idea about a small code tool related to the
application resources.
It would rely on the assumption that some global variabled,
sharing the same type and attributes, declared in group, are
contiguous.
In short I need
Is there any advice/tips for reading medium/big D codebases?
On Tuesday, 7 October 2014 at 20:55:59 UTC, Laeeth Isharc wrote:
Hi.
I am trying to create a shared library in D linked against
phobos so that I may use this in a cython extension module for
Python. Ultimately I would like to be able to use a D class or
struct (via the C++ interface) and
On Sunday, 28 September 2014 at 21:29:21 UTC, Cliff wrote:
Coming from the C# world, all of localization we did was based
on defining string resource files (XML-formatted source files
which were translated into C# classes with named-string
accessors by the build process) that would get
On Friday, 26 September 2014 at 16:43:30 UTC, Olivier Leduc wrote:
Hello,
I need to use a C++ SDK to create a plugin an existing closed
source c++ application and I would like to know if its possible
to use D for that task.
Would is be possible to port the SDK header files and call the
On Friday, 26 September 2014 at 16:43:30 UTC, Olivier Leduc wrote:
Hello,
I need to use a C++ SDK to create a plugin an existing closed
source c++ application and I would like to know if its possible
to use D for that task.
Would is be possible to port the SDK header files and call the
On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:
Hi,
I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:
with (auto p = new Panel())
{
parent = this;
text = bla;
On Friday, 26 September 2014 at 19:59:56 UTC, Freddy wrote:
On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:
Hi,
I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:
with (auto p = new Panel())
{
How do you include liblzma
bindings(https://github.com/D-Programming-Deimos/liblzma) in a
dub project?
How would you create a mutable array with a fixed(compile error
when trying to change) length.
On Monday, 11 August 2014 at 05:19:01 UTC, Jeremy DeHaan wrote:
I am looking at these versions as described here:
http://dlang.org/version.html
There are X86 and X86_64 version identifiers, but these
specifically mention that they are versions for the processor
type. Can they also be used to
I'm trying to implement a opApply outside of struct scope
struct A{
int[] arr;
}
int opApply(ref A a,int delegate(ref int) dg){
return 0;
}
void main(){
A a;
foreach(i;a){//i just want it to compile
}
}
when i try compiling, the
On Monday, 4 August 2014 at 10:30:40 UTC, Marc Schütz wrote:
On Sunday, 3 August 2014 at 23:41:27 UTC, Freddy wrote:
I am currently working on a phobos fork to include associative
ranges, however the unittest fail when i try to build. How am a
supposed test any unittests that i add.
I am currently working on a phobos fork to include associative
ranges, however the unittest fail when i try to build. How am a
supposed test any unittests that i add.
link:https://github.com/Superstar64/phobos/tree/associative_ranges
$ ../dmd/src/dmd |head -1
DMD32 D Compiler
#!/usr/bin/rdmd
import std.algorithm;
import std.stdio;
uint[uint] test;
void main(){
test=[0:2 ,1:3 ,2:4];
writeln(test.map!(a=a-2));
}
$ ./test.d
./test.d(8): Error: template std.algorithm.map cannot deduce
function from argument types !((a) = a - 2)(uint[uint]),
candidates
On Friday, 1 August 2014 at 23:22:06 UTC, bearophile wrote:
Freddy:
uint[uint] test;
void main(){
test=[0:2 ,1:3 ,2:4];
writeln(test.map!(a=a-2));
}
If you need keys or values you have .keys .values, .byKey,
.byValue (the first two are eager). If you need both you are
out
45 matches
Mail list logo