On Tue, Jul 14, 2009 at 3:04 PM, bgray<graybran...@gmail.com> wrote: > > I'm not sure if this is a binding issue or not. > > user=> (def a 1) > #'user/a > user=> (binding [a 3] (filter #(= % a) '(1 2 3))) > (1) > user=> > > In this case, I was expecting a list with 3 in it.
filter is lazy, and your lazy seq is "leaking" out of the binding dynamic scope. You must be careful with 'binding' in the presence of delayed evaluation and threads. This includes lazy-seqs, delays, futures, agents, and really closures in general. To get your expected result, simply force the seq to be realized before you return it, such as with doall, or put it into a non-lazy collection, such as with vec. user=> (binding [a 3] (doall (filter #(= % a) '(1 2 3)))) (3) --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---