Re: iota access in foreach loop

2016-06-04 Thread Alex via Digitalmars-d-learn
On Saturday, 4 June 2016 at 18:58:51 UTC, Brad Anderson wrote: On Saturday, 4 June 2016 at 18:55:09 UTC, Brad Anderson wrote: On Saturday, 4 June 2016 at 18:20:26 UTC, Alex wrote: [...] Check out enumerate() in std.range; Ah! thanks! int counter = 5; foreach(i, el;

Re: iota access in foreach loop

2016-06-04 Thread Brad Anderson via Digitalmars-d-learn
On Saturday, 4 June 2016 at 18:55:09 UTC, Brad Anderson wrote: On Saturday, 4 June 2016 at 18:20:26 UTC, Alex wrote: [...] Check out enumerate() in std.range; int counter = 5; foreach(i, el; enumerate(randomCover(iota(counter writeln("index: ", i, " element: ", el);

Re: iota access in foreach loop

2016-06-04 Thread Brad Anderson via Digitalmars-d-learn
On Saturday, 4 June 2016 at 18:20:26 UTC, Alex wrote: Hi all! Could you help me clearify why a iota can't be accessed with two arguments in a foreach loop? following tests show my problem: What does work: int[] ku = [0, 1, 2, 3, 4]; foreach(i, el; ku) writeln("index: ", i, "

Re: iota access in foreach loop

2016-06-04 Thread Alex via Digitalmars-d-learn
PPS: The error shown is in line with the iota inside foreach: Error: cannot infer argument types, expected 1 argument, not 2

iota access in foreach loop

2016-06-04 Thread Alex via Digitalmars-d-learn
Hi all! Could you help me clearify why a iota can't be accessed with two arguments in a foreach loop? following tests show my problem: What does work: int[] ku = [0, 1, 2, 3, 4]; foreach(i, el; ku) writeln("index: ", i, " element: ", el); What does not work: counter = 5;