Reductions
Last updated
Was this helpful?
Last updated
Was this helpful?
One of the core functions in Clojure is . It allows you to build up some result based on applying a function to each value in a collection. Clojure provides a similar function that builds up a (lazy) sequence of intermediate values as it is performing a reduce. This function is .
Using reduce
to sum a collection of integers looks like this
whereas reductions
performing the same task will look like this
h/t Josh Davey