Re: Iteration in lisp



On Apr 21, 5:51 pm, "rig...@xxxxxxxxx" <rig...@xxxxxxxxx> wrote:
If you want to iterate through a list, should you use a recursive
function or a loop?

Unless you have a very good reason for reinventing your own list
iteration, you should use what's already in the Common Lisp library.

So yes, one possibility is a loop. But not just any loop, but
specifically the for-as-in-list or for-as-on-list clauses of the LOOP
macro. Then there is DOLIST, the mapping applicator functions--MAPC,
MAPCAR, etc--and of course the sequences library, which combines
iteration with useful algorithm: REMOVE-IF, FIND, EVERY, ...
.



Relevant Pages

  • Re: Correct C++ tutorial part 3 "Intro to loops" available (Windows, mingw/msvc/std)
    ... >> see no reason told for this statement. ... Why would a floating point type misleading if I need a floating point value? ... do you need a floating point iteration or not? ... > loop control variables. ...
    (comp.lang.cpp)
  • Yow! LOOP macros are LOOPY!
    ... By relying entirely on procedure calls to express iteration, ... to but cleaner than C's FOR loop. ... other macros going around at the time other than MacLisp's ... (bind (vi (vector-ref v i))) ...
    (comp.lang.scheme)
  • Re: Polling, Interrupts, DMA, Synchronous, Asynchronous I/O Definitions
    ... the terminology is less useful than it might be. ... though a "message loop" could arguably be claimed to be ... considering in a particular iteration but what is true for _ALL_ ... watching the "polling" version eating up every single CPU cycle ...
    (alt.lang.asm)
  • Re: Histogram of character frequencies
    ... generated object code may simply be a loop in which elements are ... believe any C compiler anywhere would reject it. ... On the first iteration of the loop you test the end of file indicator ...
    (comp.lang.c)
  • Re: Random number help
    ... is used to generate cooccurance matrix for each iteration of for loop. ... disp('the sample co-occurance matrix is as follows');% GIVING SAME ...
    (comp.soft-sys.matlab)