Idiomatic adjacent_difference
Edwin van Leeuwen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Oct 16 04:48:17 PDT 2015
On Friday, 16 October 2015 at 11:43:16 UTC, Guillaume Chatelet
wrote:
> On Friday, 16 October 2015 at 11:38:35 UTC, John Colvin wrote:
>
> Nice !
> I wanted to use lockstep(r, r.dropOne) but it doesn't return a
> Range :-/
> It has to be used in a foreach.
Instead of lockstep you can always use zip (which is the same but
returns a range)
zip(r, r[1..$]).map!((t) => t[1]-t[0]);
More information about the Digitalmars-d-learn
mailing list