Is there an iterator or a fold-like function that will take a collection and a function and will apply the function iteratively to neighbour elements pairs until only one element remains? E.g [1,2,3]
and /
:
[1,2,3]
[1/2,2/3] # iteration 1
[3/4] # iteration 2
I can probably build something out of IterTools.partition(x,2,1)
but I am wondering if this is a common enough pattern that someone has already thought of.