exactly!!! this is great stuff indeed! I spent all morning trying to find more info than the actual docstring but I can't find anything! It seems to work as advertised though...very handy but it only works with 1.5 :-)

(reduce #(if (= 3 %2) (reduced %) (conj % %2)) [] (range 5))

=>[0 1 2]


Jim


On 16/09/12 18:15, Sean Corfield wrote:
On Sun, Sep 16, 2012 at 5:15 AM, Jim - FooBar(); <jimpil1...@gmail.com <mailto:jimpil1...@gmail.com>> wrote:

    It turns out that reduce is exactly what I need...I didn't know
    this but there is a handy 'reduced' fn that makes it easy to
    terminate from within a reduce at any given time. At least this is
    what i understand from the docs...so the final thing looks like this:


Wow, that is a super nice addition to 1.5 - I don't remember reading about that anywhere but it went in back at the end of April:

https://github.com/clojure/clojure/commit/96e8596cfdd29a2bb245d958683ee5fc1353b87a
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to