You can try in you repl with (take 1 (map (fn [_] (println "executed")) (vec (range 100)))) (take 32 (map (fn [_] (println "executed")) (vec (range 100)))) (take 33 (map (fn [_] (println "executed")) (vec (range 100))))
you will observe the 32 sized chunks. On Sat, Oct 18, 2014 at 7:36 PM, James Reeves <[email protected]> wrote: > Some lazy lists are chunked for efficiency, which means Clojure will > read-ahead and evaluate a number of elements in advance. Often the outputs > from the various list handling functions are chunked (e.g. map, range, > etc.), while creating a seq explicitly with lazy-seq will not be chunked. > > - James > > On 18 October 2014 18:28, shahrdad shadab <[email protected]> > wrote: > >> Greeting everyone, >> >> It might be stupid question but I expect >> >> (first (map (fn [_] (println "executed")) [1 2 3 4])) >> >> prints only once (realizing only first element in lazy seq returned by >> map) but it prints four times. >> Can some one shed a light why? >> >> Thanks in advance >> Best regards >> Shahrdda >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to [email protected] >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> [email protected] >> 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 [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
