digitalmars.D.learn - Unable to call each on a lockstep range containing 2 or more ranges
- maik klein (24/24) Nov 18 2015 https://stackoverflow.com/questions/33779822/unable-to-call-each-on-a-lo...
- John Colvin (8/32) Nov 18 2015 I think this is a bug, please report it at issues.dlang.org and
- maik klein (9/19) Nov 18 2015 Thanks, but the problem I have with zip is that it doesn't work
- John Colvin (9/32) Nov 18 2015 Unfortunately, yes: https://issues.dlang.org/show_bug.cgi?id=10541
- Meta (2/26) Nov 18 2015 Which version of the compiler are you using?
- maik klein (2/6) Nov 18 2015 Linux - DMD64 D Compiler v2.069.0
- Meta (3/7) Nov 18 2015 https://issues.dlang.org/show_bug.cgi?id=15357
https://stackoverflow.com/questions/33779822/unable-to-call-each-on-a-lockstep-range-containing-2-or-more-ranges http://dpaste.dzfl.pl/76c79f1f12ab void main(){ import std.container; import std.stdio; import std.algorithm.iteration; import std.range; Array!int ai = [1,2,3,4]; Array!int ai1 = [1,2,3,4]; Array!int ai2 = [1,2,3,4]; auto arange = lockstep(ai[],ai1[]); arange.each!((a,b) => writeln(a, b)); auto arange2 = lockstep(ai[],ai1[],ai2[]); arange2.each!((a,b,c) => writeln(a, b, c)); } Error: template std.algorithm.iteration.each cannot deduce function from argument types !((a, b, c) => writeln(a, b, c))(Lockstep!(RangeT!(Array!int), RangeT!(Array!int), RangeT!(Array!int))), candidates are: /opt/compilers/dmd2/include/std/algorithm/iteration.d(820): std.algorithm.iteration.each(alias pred = "a") "arange" works but "arange2" doesn't because the compiler is unable to deduce the the function. The error even appears if I explicitly add the argument types.
Nov 18 2015
On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote:https://stackoverflow.com/questions/33779822/unable-to-call-each-on-a-lockstep-range-containing-2-or-more-ranges http://dpaste.dzfl.pl/76c79f1f12ab void main(){ import std.container; import std.stdio; import std.algorithm.iteration; import std.range; Array!int ai = [1,2,3,4]; Array!int ai1 = [1,2,3,4]; Array!int ai2 = [1,2,3,4]; auto arange = lockstep(ai[],ai1[]); arange.each!((a,b) => writeln(a, b)); auto arange2 = lockstep(ai[],ai1[],ai2[]); arange2.each!((a,b,c) => writeln(a, b, c)); } Error: template std.algorithm.iteration.each cannot deduce function from argument types !((a, b, c) => writeln(a, b, c))(Lockstep!(RangeT!(Array!int), RangeT!(Array!int), RangeT!(Array!int))), candidates are: /opt/compilers/dmd2/include/std/algorithm/iteration.d(820): std.algorithm.iteration.each(alias pred = "a") "arange" works but "arange2" doesn't because the compiler is unable to deduce the the function. The error even appears if I explicitly add the argument types.I think this is a bug, please report it at issues.dlang.org and perhaps there will be an explanation or it will be fixed. In the mean time, something like this should work: auto arange2 = zip(ai[],ai1[],ai2[]); arange2.each!((t) => writeln(t[0], t[1], t[2])); // or if you really must have the names: arange2.each!((t) => (a,b,c){ writeln(a, b, c); }(t.expand));
Nov 18 2015
On Wednesday, 18 November 2015 at 13:51:59 UTC, John Colvin wrote:On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote:Thanks, but the problem I have with zip is that it doesn't work with "ref". for example auto arange3 = zip(ai[],ai1[],ai2[]); foreach(ref a; arange3){ a[0] = 42; } Won't change anything. Is this another bug?[...]I think this is a bug, please report it at issues.dlang.org and perhaps there will be an explanation or it will be fixed. In the mean time, something like this should work: auto arange2 = zip(ai[],ai1[],ai2[]); arange2.each!((t) => writeln(t[0], t[1], t[2])); // or if you really must have the names: arange2.each!((t) => (a,b,c){ writeln(a, b, c); }(t.expand));
Nov 18 2015
On Wednesday, 18 November 2015 at 14:11:45 UTC, maik klein wrote:On Wednesday, 18 November 2015 at 13:51:59 UTC, John Colvin wrote:Unfortunately, yes: https://issues.dlang.org/show_bug.cgi?id=10541 Note that while(!arange3.empty) { arange3.front[0] = 42; arange3.popFront(); } should work as expected.On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote:Thanks, but the problem I have with zip is that it doesn't work with "ref". for example auto arange3 = zip(ai[],ai1[],ai2[]); foreach(ref a; arange3){ a[0] = 42; } Won't change anything. Is this another bug?[...]I think this is a bug, please report it at issues.dlang.org and perhaps there will be an explanation or it will be fixed. In the mean time, something like this should work: auto arange2 = zip(ai[],ai1[],ai2[]); arange2.each!((t) => writeln(t[0], t[1], t[2])); // or if you really must have the names: arange2.each!((t) => (a,b,c){ writeln(a, b, c); }(t.expand));
Nov 18 2015
On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote:https://stackoverflow.com/questions/33779822/unable-to-call-each-on-a-lockstep-range-containing-2-or-more-ranges http://dpaste.dzfl.pl/76c79f1f12ab void main(){ import std.container; import std.stdio; import std.algorithm.iteration; import std.range; Array!int ai = [1,2,3,4]; Array!int ai1 = [1,2,3,4]; Array!int ai2 = [1,2,3,4]; auto arange = lockstep(ai[],ai1[]); arange.each!((a,b) => writeln(a, b)); auto arange2 = lockstep(ai[],ai1[],ai2[]); arange2.each!((a,b,c) => writeln(a, b, c)); } Error: template std.algorithm.iteration.each cannot deduce function from argument types !((a, b, c) => writeln(a, b, c))(Lockstep!(RangeT!(Array!int), RangeT!(Array!int), RangeT!(Array!int))), candidates are: /opt/compilers/dmd2/include/std/algorithm/iteration.d(820): std.algorithm.iteration.each(alias pred = "a") "arange" works but "arange2" doesn't because the compiler is unable to deduce the the function. The error even appears if I explicitly add the argument types.Which version of the compiler are you using?
Nov 18 2015
On Wednesday, 18 November 2015 at 17:22:52 UTC, Meta wrote:On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote:Linux - DMD64 D Compiler v2.069.0[...]Which version of the compiler are you using?
Nov 18 2015
On Wednesday, 18 November 2015 at 17:40:21 UTC, maik klein wrote:On Wednesday, 18 November 2015 at 17:22:52 UTC, Meta wrote:https://issues.dlang.org/show_bug.cgi?id=15357 https://issues.dlang.org/show_bug.cgi?id=15358Which version of the compiler are you using?Linux - DMD64 D Compiler v2.069.0
Nov 18 2015