Adjacent Pairs Range

deed via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 12 18:49:54 PDT 2015


On Saturday, 12 September 2015 at 10:17:19 UTC, Nordlöw wrote:
> How do I most elegantly iterate all the adjacent pairs in an 
> `InputRange` using Phobos?
>
> Something like
>
>     [1,2,3,4] => [(1,2), (2,3), (3,4)]

Why not just:

zip(arr[0 .. $-1], arr[1 .. $])

?


More information about the Digitalmars-d-learn mailing list