Re: Recursive lambda functions?
Use Y combinator? http://forum.dlang.org/thread/mailman.157.1385247528.2552.digitalmars-d-le...@puremagic.com#post-l6rgfq:24g5o:241:40digitalmars.com
Re: Recursive lambda functions?
On Monday, 30 December 2013 at 21:15:43 UTC, Ilya Yaroshenko wrote: I want something like enum factrorial5 = (a = a == 0 ? 1 : a * __lambda(a-1))(5); //Recursive pure lambda function That isn't supported in D. And cases where this would be useful are too rare to add complexity to the language. Just use a regular function, it's not much more code.
Re: Reading file by line, weird result
The solution is to append `line.dup` instead of `line`. I guess this note in the documentation should be marked red: Each front will not persist after popFront is called, so the caller must copy its contents (e.g. by calling to!string) if retention is needed.
Re: joiner correct usage
On Wednesday, 25 December 2013 at 18:41:47 UTC, H. S. Teoh wrote: import std.array : array; import std.algorithm : joiner; string joined = joiner([hello, world], ).array; T Ha! Error: cannot implicitly convert expression (array(joiner([hello, world], ))) of type dchar[] to string std.conv.to should be used instead: import std.conv : to; string joined = joiner([hello, world], ).to!string;
Re: Circular Buffer
Use std.range.cycle with std.container.Array (slice the array to get a range). http://dlang.org/phobos/std_range.html#.cycle
Re: Travis-CI and D
Yep. In 'before_install' download a D compiler and add it to $PATH; in 'script' specify commands for running tests.
Re: Performance of ranges verses direct
On Friday, 13 December 2013 at 18:03:28 UTC, Nikolay wrote: Results: ~/ldc2-0.12.0-linux-x86_64/bin/ldmd2 -O -release -inline zip_test.d ./zip_test --limit 1000 … 0 - 0 1 - 764 And now try -inline-threshold=1024 ;-) Reading -help-hidden sometimes helps.
Re: How to install dmd2 in centos 5.3 x64
Did you install binaries or build the compiler from source?
Re: Is anything private by default when declared in a module?
On Monday, 2 December 2013 at 20:53:10 UTC, Namespace wrote: But sadly named imports aren't private... OMG now I get it why in 2.064 importing std.regex makes visible std.uni.isWhite all of a sudden.
Re: How to make delegate refer to itself?
Why so much fuss about delegates? I would simply define an interface. // factory function for simple cases queue.register(eventHandler((Event e) { ... })); // here, 'this' is available class SomeComplicatedHandler : IEventHandler { ... }
Re: What is the closest to ConcurrentHashMap and NavigableMap in Java?
On Thursday, 14 November 2013 at 17:36:09 UTC, Jacek Furmankiewicz wrote: Could anyone point me to what would be the closest D equivalents (maybe in an external library if not part of Phobos) so we can playing around with them? Much appreciated Jacek In such cases the easiest route is to find some C/C++ library for such tasks, make a C interface in the latter case, and link with it. That would require a bit of extra work but much less than writing your own performant implementation from scratch. E.g. I once wrote a simple wrapper for the Kyoto Cabinet key-value store: https://github.com/lomereiter/kyoto-d/blob/master/kyotocabinet.d
Re: spurious gc allocation
Indeed, disassembly reveals an allocation (with all three compilers = it's the front-end which generates this crap). I guess the compiler incorrectly treats { node.value; } as a delegate and copies the node to GC heap. void foo() { int* node = null; enum mutable = __traits(compiles, {node.value ;}); } void main() { foo(); }
Re: D language manipulation of dataframe type structures
I thought about it once but quickly abandoned the idea. The primary reason was that D doesn't have REPL and is thus not suitable for interactive data exploration.
Re: Conditional Inheritance
Thanks. Now I realise that D is much less intuitive than C++.
Re: Conditional Inheritance
I assume that you template ends up creating a dummy interface though and this isn't really acceptable. Yes, it does. Once ':' is typed, some inheritance must occur. Why isn't a dummy interface acceptable?
Re: Conditional Inheritance
This should work: template conditionallyInherit(bool inherit, T) { static if (inherit) alias T conditionallyInherit; else interface conditionallyInherit {} }
Re: Conditional Inheritance
On Sunday, 14 July 2013 at 05:04:37 UTC, JS wrote: and while I'm at it I need to conditionally constrain types. interface A(T) where(!isBasicType!T, (T : B)); which is suppose to require T to inherit from B if T is not basic type. interface A(T) if (isBasicType!T || is(T : B))
Re: how to reflect on function attributes
This doesn't work when the method is marked as @property. Any idea why is that so? On Wednesday, 5 June 2013 at 02:19:38 UTC, Jonathan M Davis wrote: is(typeof(A.func) == const) - Jonathan M Davis
Re: joiner and map, strange behavior
Current implementation of joiner accesses each element two times - first, in a loop which skips empty ranges, plus after the loop assignment to a variable occurs: https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L2993 On Tuesday, 12 March 2013 at 17:51:57 UTC, Stephan Schiffels wrote: Thanks, I had a brief look at std.algorithm.joiner but couldn't find anything obvious, maybe I should look deeper into it.
Re: question when writing to a file
Indeed, that shouldn't be the case. I filed a bug request: http://d.puremagic.com/issues/show_bug.cgi?id=9661 While it isn't fixed, assign file to a variable so that it doesn't go out of scope. On Thursday, 7 March 2013 at 16:20:24 UTC, bioinfornatics wrote: I only replace write by put and do this: auto output = File( f.absolutePath().expandTilde(), w ).lockingTextWriter(); that build without get an error but at runtime i got: std.exception.ErrnoException@/env/export/nfs2/cns_prog/opt/gdc/include/d/4.7.2/std/stdio.d(1267): (Bad file descriptor)
Re: Googling about D
I often search libraries on Github — it allows to filter results by language, and probably most D libraries are anyway hosted there.