DOTIMES
Classic LISP iteration macro, implemented as special form in LabLISP. Expects at least one argument, which must be properly formed list: First element is a plain symbol, which will be the counter variable. Second element must evaluate to integer - number of loops. There might be optional third element, the result form - single expression which will be evaluated after the looping is finished. If there is no result expression, the DOTIMES
form returns NIL
.
After the initializer list, there can be any number of expressions (implicit PROGN
), which will be evaluated repeatedly in loop.
>(dotimes (i 3) (print i)) ; loop will run 3 times 0 ; I starts from 0 1 2 NIL ; DOTIMES returns NIL
Note that the optional result form is evaluated in the context where the counter symbol is still defined and has the integer value of the number of loops done.
>(dotimes (i 3 i) (print "loop")) "loop" "loop" "loop" 3 ; result form has value 3
See also: DOLIST
, RETURN