(class (range 10))
;=> clojure.lang.LazySeq
(class (seq (range 10))
;=> clojure.lang.ChunkedCons
From my understanding, LazySeq is already an sequence, since:
(seq? (range 10))
;=> true
I guess I have an answer.
That's because using seq
enforces the evaluation of the first element of LazySeq
. Because seq
returns nil
when the collection & sequence is empty, it has to eval the element to decide that.
That's the exactly reason why rest
is lazier than next
, because (next s)
is just (seq (rest s))
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With