Lazy reduce in Clojure

We’re big fans of Clojure at Altometrics. It really gets out of the way and lets us get stuff done without a lot of fuss. Like many functional programming languages, Clojure features lazy sequences, which are especially useful if a given sequence is too big to fit into memory. (I’ll call such sequences “large” for the purposes of this post.)

I recently wrote the following Clojure function to lazily reduce a large sequence. I couldn’t find a Clojure function that does this, so I figured it would be worth sharing. The discussion follows, but first, here’s the code:

Continue reading “Lazy reduce in Clojure”