lockstep works with .each, but fails with .map
realhet
real_het at hotmail.com
Fri Mar 5 19:50:01 UTC 2021
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 to use other range functions, you should use `zip` instead
> of `lockstep`.
It works now:
zip(StoppingPolicy.requireSameLength, a, b).map!(a =>
SE(a[])).sum / float(a.length);
I had a misconception (lazyness of learning) that zip is making a
simple array, not a tuple array like I guessed lockstep does.
Also in zip() the StoppingPolicy is the first parameter and in
lockstep() it's the last.
Thank you very much!
More information about the Digitalmars-d-learn
mailing list