I'm glad you pointed this out! On stackoverflow everyone was assuming 
filter was completely lazy in all cases

On Sunday, May 19, 2013 at 4:54:53 PM UTC+2, Jim foo.bar wrote:
>
> 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(); <jimpi...@gmail.com 
> <javascript:>> 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 clo...@googlegroups.com <javascript:>
> 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 <javascript:>
> 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 <javascript:>.
> 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/d/optout.

Reply via email to