for, foreach identifier allowed in c throws error in d

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 2 13:23:12 PDT 2014


On Mon, 02 Jun 2014 15:58:01 -0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:


> I'm trying to think of a way to do this without loops, but not sure.

I'm surprised, I looked for some kind of "apply" function like map, but  
just calls some function with each element in the range.

Something like this would make this a 1 (2?) liner:

if(i == t.length) writeln(t) else each!((x) => {t[i] = x;  
foo(i+1);})(iota(x.length));

But I can't find a phobos primitive for each. Would have expected it in  
std.algorithm or std.functional?

-Steve


More information about the Digitalmars-d-learn mailing list