There are only 9 items that satisfy your predicate. (take 10 ...) demands a 10th, and it keeps searching the (iterate inc 1) stream forever, endlessly searching for that 10th item it will never find.
On Wed, Dec 9, 2009 at 9:41 PM, Mike K <mbk.li...@gmail.com> wrote: > On Dec 9, 10:35 pm, Mike K <mbk.li...@gmail.com> wrote: > >> The first two work but the third one hangs. Why? > > user> (take 5 (filter #(< % 10) (iterate inc 1))) > (1 2 3 4 5) > > OK, I figured out that it won't hang with taking <= 9 elements, which > is the total that pass the filter. > > But shouldn't it give me 9 items without hanging when I ask for 10 or > more as in the first case? > > Mike > > -- > 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 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