Next: return, Up: Unconditional Execution [Contents][Index]
do {expr}* doing {expr}*
construct simply evaluates the specified expressions wherever they occur in the expanded form of loop.
expr
argument can be any non-atomic Common Lisp form. Each expr
is evaluated in
every iteration.
The constructs
are the only loop keywords that take an arbitrary number of forms and group
them as if using an implicit progn
.
Because every loop clause must begin with a loop keyword, you would use the keyword ‘do’ when no control action other than execution is required.
;;; Print some numbers. (loop for i from 1 to 5 do (print i)) ;Prints 5 lines
;;; Print numbers and their squares. ;;; The DO construct applies to multiple forms. (loop for i from 1 to 4 do (print i) (print (* i i))) ;Prints 8 lines