As stated above, what is the underlying data structure of a lazy sequence ? Is it a list ? If it is, then what kind of list is it ? Where can I find references about this ?
Asked
Active
Viewed 116 times
1
-
see this question http://stackoverflow.com/questions/3247045/how-are-lazy-sequences-implemented-in-clojure – joshua Dec 05 '14 at 12:31
1 Answers
3
The data structure is a clojure.lang.Lazyseq, defined here. The lazy-seq macro creates such.
As you can see, a LazySeq is essentially a linked list which starts life with a thunk (zero-parameter function) member fn. When the sequence is realized, fn is used to generate data member s or sv and is itself annulled. I can't quite figure out how s and sv relate to one another.
Thumbnail
- 13,293
- 2
- 29
- 37