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)]

What about using zip and a slice?

```
void main()
{
        auto a = [1,2,3,4];
        import std.range : zip;
        import std.stdio;
writeln(a.zip(a[1..$])); // [Tuple!(int, int)(1, 2), Tuple!(int, int)(2, 3), Tuple!(int, int)(3, 4)]
}
```

Reply via email to