I have a simple sequence of arbitrary elements that I would like to reduce over two-by-two.
In order to do that, I generate pairs with the data, but the way I do it is wrong since I need to call a function generating the data twice :
(defn gen-pairs [l]
(partition 2 (drop 1 (take l (interleave (gen-data) (gen-data))))))
How can I avoid calling gen-data twice (gen-data returns a sequence of items lazily, like range for instance) ?
interleavethat took thegen-datafunction as its parameter.