XLISP >
XLISP 2.0 -
Contents -
Reference -
Previous |
Next
20 Looping Constructs
- loop - basic looping form
- do - loop while the termination test is NIL
- do* - 'do' loop with sequential binding
- dolist - loop through a list
- dotimes - loop from zero to n-1
- (loop expr...)
- basic looping form
- expr - the body of the loop
returns - never returns (must use non-local exit)
- (do (binding...)
(texpr rexpr...) expr...)
(do* (binding...)
(texpr rexpr...) expr...)
- 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 - is the initial value of the symbol
step - is 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
- (dolist (sym
expr [rexpr]) expr...)
- loop through a list
- 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]
- (dotimes (sym
expr [rexpr]) expr...)
- loop from zero to n-1
- sym - the symbol to bind to each value from 0 to n-1
expr - the number of times to loop
rexpr - the result expression [the default is NIL]
expr - the body of the loop [treated like an implicit prog]
XLISP >
XLISP 2.0 -
Contents -
Reference -
Previous |
Next