Hello.

2012/6/11 Yoshinori Kohyama <[email protected]>:
> If clojure's implementation of reverse don't consume stack, how does it do?

`reduce1` is a recursive function using `recur`, explicit tail
recursion with optimization.  So it doesn't.

> The source of 'reverse' says it uses 'reduce1' and commented "Not lazy".

Yes.  `reverse` must be strict, because all elements must be realized
(the value is computed) when you reverse a sequence.

> The source of 'reduce1' says it uses 'chunk-seq?', '.reduce', 'chunk-first'
> and 'chunk-next'.
> What are these?

See clojure.lang.{IChunk,IChunkedSeq}.

> And is there any lazy solution?

Probably no.  Both `fold-right` and `reverse` must be strict IMHO.

-- 
OGINO Masanori <[email protected]>
http://twitter.com/omasanori

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
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

Reply via email to