You didnt try this, as I can judge, because you responded in finite time ;-)
(fib0 35) takes 20 seconds already. So your suggestion (time (doall (map fib0 (range 100))) will do all up to 100, time it, and print the first ten, in that order. (fib0 100) takes a good while (I just estimaded 15 million years on my computer) But, well, this one wont be that quick: > (time (doall (map fib0 (iterate inc 1))) ;-) My main irritation is still: Why do my range and my iterate version differer in their print beheavior? Greetings, alux Meikel Brandmeyer schrieb: > Hi, > > On Mar 19, 11:27 am, alux <alu...@googlemail.com> wrote: > > > user=> (time (fib0 35)) > > "Elapsed time: 20874.18345 msecs" > > 24157817 > > > > user=> (time (map fib0 (iterate inc 1))) > > "Elapsed time: 0.913524 msecs" > > (2 3 5 8 13 21 34 55 89 144 ...) > > > > Everything fine. > > Now what puzzles me: > > > > user=> (time (map fib0 (range 100))) > > "Elapsed time: 1.248203 msecs" > > As you write in your subject. You are caught by laziness. Wrap the map > in a doall. > > (time (doall (map fib0 (iterate inc 1))) > (time (doall (map fib0 (range 100))) > > (Don't forget to set print-length!) > > What happens? The map returns not a list of sorts but an object, which > computes the result when it is requested. So it completes very fast, > hence the short time reported by the time call. Now outside the time > call the object is received by the Repl which triggers the suspended > computation and prints the result. So the actual work happens outside > the time call. On the other hand, wrapping the map into a doall will > realise the computation immediately (that is inside the time call) and > work will actually show up in form of a longer time reported by time. > > Sincerely > Meikel -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.