Looping Constructs
basic looping form
(loop <expr>...)
fsubr
<expr> the body of the loop
returns never returns (must use non-local exit, such as return)
general looping form
(do (<binding>...) (<texpr> <rexpr>...) <expr>...)
(do* (<binding>...) (<texpr> <rexpr>...) <expr>...)
fsubr. do binds simultaneously, do* binds sequentially
<binding> the variable bindings each of which is either:
1) a symbol (which is initialized to NIL)
2) a list of the form: (<sym> <init> [<step>])
where:
<sym> is the symbol to bind
<init> the initial value of the symbol
<step> a step expression
<texpr> the termination test expression
<rexpr> result expressions (the default is NIL)
<expr> the body of the loop (treated like an implicit prog)
returns the value of the last result expression
loop through a list
(dolist (<sym> <expr> [<rexpr>]) <expr>...)
fsubr
<sym> the symbol to bind to each list element
<expr> the list expression
<rexpr> the result expression (the default is NIL)
<expr> the body of the loop (treated like an implicit prog)
returns the result expression
loop from zero to n-1
(dotimes (<sym> <expr> [<rexpr>]) <expr>...)
fsubr
<sym> the symbol to bind to each value from 0 to n-1
<expr> the number of times to loop (a fixnum)
<rexpr> the result expression (the default is NIL)
<expr> the body of the loop (treated like an implicit prog)
returns the result expression |