Hi all,
I'm trying to come up with a way to create a 'tournament' fn that
basically alternates between players (in turns) and calls soem 'move' fn
on each. Now, obviously this can be done with loop/recur no problem,
however perhaps a combination of cycle iterate is more
appropriate...so
Hi again,
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:
(defn tournament
On Sun, Sep 16, 2012 at 5:15 AM, Jim - FooBar(); jimpil1...@gmail.comwrote:
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
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]