Why should it build a concrete result? Here's my reasons why it makes sense to be lazy here:
- It would use more memory otherwise. Since, if you are transforming a list to a set there's got to a transformed copy of the original data structure when it's materialized. - It might take longer than necessary to calculate. Suppose you've threaded the result into (take n), now, you need to call the predicate of map only n times. If you think about large data structures (maybe even infinite sequences), laziness makes more sense. On Sat, Feb 8, 2014 at 2:19 AM, Andy C <andy.coolw...@gmail.com> wrote: > Hi, > > I have a short question, why map builds up a LazySeq instead of an input > collection as found below: > > user=> (type (map #(mod % 3) #{3 6})) > clojure.lang.LazySeq > user=> (type (map #(mod % 3) '(3 6))) > clojure.lang.LazySeq > user=> (type (map #(mod % 3) [3 6])) > clojure.lang.LazySeq > user=> (type (map #(mod (% 1) 3) {:a 3, :b 6})) > clojure.lang.LazySeq > > > One would expect to "(map #(mod % 3) #{3 6})" evaluate into "#{0}". Is it > arbitrary decision or there is a theory behind it? > > Best, > Andy > > -- > 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/groups/opt_out. > -- Kind Regards, Atamert Ölçgen -+- --+ +++ www.muhuk.com -- 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/groups/opt_out.