On Saturday 29 November 2008 06:55, Randall R Schulz wrote: > ... > > It's a good technique, though, to see what the compiler is going to > be asked to translate after all players between the form as submitted > and the compiler have done their thing.
Or is it? Can you tell what a newbie I am? I'm working my way through Stuart H.'s book. I'm on the sequence section (4.2) and just got to "for". Here's what I did / found: user=> (doc for) ------------------------- clojure.core/for ([seq-exprs expr]) Macro List comprehension. ... (take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y])) nil So seeing that "for" is a macro, I thought I'd see what it produces. I started with the example included in the doc string: user=> (macroexpand '(take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y]))) (take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y])) So next I tried macroexpand -ing just the (for ...) sub-form: user=> (macroexpand '(for [x (range 100000000) y (range 1000000) :while (< y x)] [x y])) (let* [iter__3869 (clojure.core/fn iter__33 [s__34] (clojure.core/when-first [x s__34] (if true (clojure.core/let [iterys__3867 (clojure.core/fn iter__35 [s__36] (clojure.core/when-first [y s__36] (if (< y x) (clojure.core/lazy-cons [x y] (iter__35 (clojure.core/rest s__36))) nil))) fs__3868 (iterys__3867 (range 1000000))] (if fs__3868 (clojure.core/lazy-cat fs__3868 (iter__33 (clojure.core/rest s__34))) (recur (clojure.core/rest s__34)))) nil)))] (iter__3869 (range 100000000))) I'm somewhat confused by this, but I gather it has something to do with "take" being lazy? > > --Steve Randall Schulz --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---