3 ms·
One my favorite features that came out of reducers - short circuiting reduce! (reduce (fn [a b] (if (> a 100) (reduced a) (+ a b))) (ran
by swannodette 14y ago
One my favorite features that came out of reducers - short circuiting reduce!
(reduce
(fn [a b]
(if (> a 100) (reduced a) (+ a b)))
(range 100000))
=> 105
I've often had to use loop/recur instead of reduce because you could not short circuit. No longer.
- malkia 14y agoThis is so beautiful, like recur's blessing in disguise.
- invalidOrTaken 14y agoYES, I was hunting around for this in 1.4, happy to see it's arrived.
- k0t0n0 14y agocool