Thanks,
Jeff
Am 10.02.2009 um 18:00 schrieb Jeff Rose:
> Oh cool! I hadn't thought about this aspect of laziness before. I
> can
> see there is some zen here that is worth exploring...
Many ways to Rome:
(first (drop-while (complement predicate) coll))
:)
Sincerely
Meikel
... or just (comp first filter)
((comp first filter) odd? [2 4 6 7 8 9])=> 7--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
no need to traverse the entire seq with 'filter' if you only want the 1st match...
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