On Fri, 2011-12-16 at 16:10 +0100, Tassilo Horn wrote: > A lazy seq is basically a sequence of the first element and a "thunk", > where a thunk is a function without parameters that knows how to > calculate the rest of the lazy sequence. When you call `rest' or `next' > on a lazy seq, that thunk is called computing the next item (realizing > it) and the next thunk, which again knows how to compute the rest of the > seq.
While some lazy sequences are implemented that way, Clojure's lazy sequences are more like "even" streams than those "odd" streams. Lazy seqs contain *only* the thunk; additionally, that thunk is not required to yield any further lazy behavior. For example: (lazy-seq (prn "In an odd stream, this would be evalled immediately for the 7") [7 14 21 28 35] ;; and there is no thunk that represents (14 21 28 35), separating ;; lazy seqs from *both* odd and even streams ) (lazy-seq (prn "and this lazy seq has no first element to speak of") nil) -- Stephen Compall ^aCollection allSatisfy: [:each|aCondition]: less is better -- 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