On May 16, 2009, at 8:23 PM, Michel S. wrote:

That's a bit of a red herring, though? You can always rewrite the code
to use normal (as opposed to tail) recursion, if you don't want to use
reverse. Depending on how large the resulting list is, it's a space- vs-
time tradeoff: the normal recursive version is probably faster but
uses (a constant factor of) more memory.

I don't think recursion is the issue. Producing results in order and producing an in-order collection as the result involves "adding" elements to the end of a collection.

Appending is efficient for (Clojure) vectors, but not for lists.

To work around that problem, one can cons the results onto the beginning of a list (which is efficient) and then reverse the result at the end.

Efficient vectors in Clojure allow us to skip that workaround.

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to