On Wed, Mar 11, 2009 at 9:01 AM, Vagif Verdi <vagif.ve...@gmail.com>
wrote:
> Is (first (filter ..) lazy like in haskell ?

It's lazy in the sense that it will only consume the sequence up to
first positive result.

If it doesn't find one, it will consume the entire sequence and return
nil.

Therefore, this form is not safe on infinite sequences!
For example,  (first (filter neg? (iterate inc 0)))  never terminates.

-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
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
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