Hacker News new | ask | show | jobs
by swannodette 4862 days 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.
3 comments

YES, I was hunting around for this in 1.4, happy to see it's arrived.
This is so beautiful, like recur's blessing in disguise.
cool