Clojure: See every step of a reduce

Last year I wrote about a Haskell function called scanl which returned the intermediate steps of a fold over a collection and last week I realised that I needed a similar function in Clojure to analyse a reduce I'd written.

A simple reduce which adds together the numbers 1-10 would look like this:

> (reduce + 0 (range 1 11))
55

If we want to see the intermediate values of this function called then instead of using reduce there's a function called reductions which gives us exactly what we want:

I initially thought the reductions function was only useful as a debugging tool and that you'd always end up changing your code back to use reduce after you'd solved the problem but I realise I was mistaken.