Re: Iteration in lisp



"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. Anyone who tells you otherwise is living in a
fantasy world or is telling you something implementation-dependent or
is confusing Lisp with Scheme.
.



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: Python syntax in Lisp and Scheme
    ... > I am just barely familiar with Lisp and Scheme. ... > comp.lang.python comparing a simple loop. ... Well, over in comp.lang.lisp (where we speak Common Lisp, more so than ... I have looked for repositories of such macros and I ...
    (comp.lang.lisp)
  • 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: Newbie: reverse or append?
    ... It seems to me that you are trying to program in Scheme instead of ... Common Lisp. ... Here is a version of what you are trying to do using Common Lisp's LOOP ... Tyler: "How's that working out for you?" ...
    (comp.lang.lisp)
  • Re: Newbie: reverse or append?
    ... > Common Lisp. ... > Here is a version of what you are trying to do using Common Lisp's LOOP ... >> internally and the length function accesses it somehow. ... I do come from the realm of Scheme... ...
    (comp.lang.lisp)