Iterate for previous and current elements

julia> using IterTools

julia> for (prev, this) in partition(1:5, 2, 1)
       println(prev, " and ", this)
       end
1 and 2
2 and 3
3 and 4
4 and 5
8 Likes