On Tue, Apr 6, 2010 at 9:59 PM, Christophe Grand <christo...@cgrand.net> wrote: > Btw, to some extent, one can create cyclic data-structures in Clojure (only > lazyseqs though -- unless you implement your own map or use lazy-map etc.) : > user=> (defn cyclic-seq [coll] (let [s (promise)] @(deliver s (lazy-cat coll > @s)))) > user=> (let [s (cyclic-seq [1 2 3])] (identical? (seq s) (seq (drop 3 s)))) > true
I've already mentioned it a few times in passing, but my letrec macro uses promises and some simple-minded code walking to abstract away this kind of thing. The included example code is a pair of mutually cyclic lazy-seqs. http://gist.github.com/336461 -Per -- 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, reply using "remove me" as the subject.