ha! you cheated with iterate...
try this which is closer to the example...
(first (filter odd? (map #(do (println "realized " %) %) [2 4 6 7 8 9])))
realized 2
realized 4
realized 6
realized 7
realized 8
realized 9
7
Jim
On 19/05/13 15:31, Cedric Greevey wrote:
On Sun, May 19, 2013 at 10:06 AM, Jim - FooBar();
<jimpil1...@gmail.com <mailto:jimpil1...@gmail.com>> wrote:
no need to traverse the entire seq with 'filter' if you only want
the 1st match...
Pretty sure filter is lazy.
user=> (first (filter odd? (map #(do (println "realized " %) %)
(iterate inc 0))))
realized 0
realized 1
1
user=>
--
--
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 unsubscribe from this group and stop receiving emails from it, send
an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
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 unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.