Re: Iteration in lisp



Kent M Pitman <pitman@xxxxxxxxxxx> wrote:

"rigaha@xxxxxxxxx" <rigaha@xxxxxxxxx> writes:

If you want to iterate through a list, should you use a recursive
function or a loop?

In Common Lisp, always prefer a loop where practical unless you know
with relative certainty that the problem cannot grow very big. A
recursive function can run out of stack since CL does not guarantee
tail call elimination.

Any pointers to the rationale for this decision?
.



Relevant Pages

  • Re: do expression
    ... assignments be executed during execution of the do loop ... do (funcall g th2) ... the Common Lisp version above is incorrect. ... What needs to be done in a translation of binding semantics to assignment semantics is that new local bindings are created manually in each iteration, so that they can persist, and that all references go to those local bindings. ...
    (comp.lang.scheme)
  • Re: Common Lisp implementations are still multiple times slower than C
    ... In another thread in this newsgroup some people wrote that Common Lisp can ... Java compiler to create an efficient version. ... (loop for y from 0 below height ... (if (zerop cell) ...
    (comp.lang.lisp)
  • Re: Why Im giving up on Lisp for now
    ... >> Over the last few months I've made an effort to learn Common Lisp, ... >> never work first time, and I have to experiment with quotes, ... > Macros can be tricky. ... loop takes two minutes instead of two seconds. ...
    (comp.lang.lisp)
  • Re: LOOP probblems
    ... Common Lisp Loop Macro" couldn't help me! ... Don't say (gethash c 'mappings), ...
    (comp.lang.lisp)
  • Re: if then else
    ... > clearer than using IF, WHEN, UNLESS, and COND. ... > deeply disturbed by IF* since Common Lisp has perfectly good ... I would've liked to have seen a serious discussion on DO vs. LOOP -- ...
    (comp.lang.lisp)