Re: lockstep works with .each, but fails with .map

2021-03-05 Thread realhet via Digitalmars-d-learn
On Friday, 5 March 2021 at 19:26:38 UTC, Jacob Carlborg wrote: On 2021-03-05 19:49, realhet wrote: Why it works with each (or foreach), but not with map? o.O `lockstep` is specifically designed to work with `foreach`. I think `each` has a special case to work with `lockstep`. If you want

Re: lockstep works with .each, but fails with .map

2021-03-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-03-05 19:49, realhet wrote: Why it works with each (or foreach), but not with map? o.O `lockstep` is specifically designed to work with `foreach`. I think `each` has a special case to work with `lockstep`. If you want to use other range functions, you should use `zip` instead of

lockstep works with .each, but fails with .map

2021-03-05 Thread realhet via Digitalmars-d-learn
Hi What am I doing wrong here? import std.stdio, std.range, std.algorithm, std.uni, std.utf, std.conv, std.typecons, std.array; auto SE(A, B)(in A a, in B b){ return (a-b)^^2; } void main(){ auto a = [1, 2, 3], b = [1, 1, 1]; lockstep(a, b,