Imagine you have a vector
[1,2,3,4] and would like to have easily access adjacent elements:
I used to do it with a
for loop and then just access the
i+1-th element while looping over
length()-1. This seems rather ugly so I made a pairwise iterator
pairwise(x) = zip(x, last(Iterators.peel(x)))
for (x,y) in pairwise("abcd") @show x*y end
x * y = "ab" x * y = "bc" x * y = "cd"
Am I reinventing the wheel? Is there anything better?