On Seq, no, but you can use a transducer to make it read-ahead. Eg : https://gist.github.com/cgrand/c8fa256c9ed8331f9cf1
from Christophe Grand. On Oct 18, 2014 8:18 PM, "shahrdad shadab" <clojure.langu...@gmail.com> wrote: > Thanks a lot for your explanation, the thing that confuses me was the same > function used with "repeatedly" only prints once: > > (first (repeatedly 4 #(do (println "executed!") (inc 1)))) > > I guess because Clojure does not read-ahead in this scenario. Am I right? > > On Sat, Oct 18, 2014 at 1:41 PM, Jonathan Winandy < > jonathan.wina...@gmail.com> wrote: > >> 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 <ja...@booleanknot.com> >> 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 <clojure.langu...@gmail.com> >>> 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 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/d/optout. >>>> >>> >>> -- >>> 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/d/optout. >>> >> >> -- >> 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/d/optout. >> > > -- > 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/d/optout. > -- 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/d/optout.