Clojure Function
(reductions + 0 (cycle [1 1 -1]))
creates the sequence [0 1 2 1 2 3 2 3 4 3 4 5 ...]. Unfortunately, this sequence was not lazy.
As cycleand reductionstwo documented as returning a lazy sequence, I had expected that the combination of these functions returns a lazy sequence. Why is this not the case and how can I fix it to return the sequence lazily?
A more complex example that shows the same problem:
(reductions (fn [x f] (f x)) 0 (cycle [inc inc dec]))
(I show this because this is the version I would like to work with at the end, in case that matters)
source
share