Iteration Clauses
-----------------
Aside from `for' clauses, there are several other loop clauses that
control the way the loop operates. They might be used by themselves,
or in conjunction with one or more `for' clauses.
`repeat INTEGER'
This clause simply counts up to the specified number using an
internal temporary variable. The loops
(loop repeat n do ...)
(loop for temp to n do ...)
are identical except that the second one forces you to choose a
name for a variable you aren't actually going to use.
`while CONDITION'
This clause stops the loop when the specified condition (any Lisp
expression) becomes `nil'. For example, the following two loops
are equivalent, except for the implicit `nil' block that surrounds
the second one:
(while COND FORMS...)
(loop while COND do FORMS...)
`until CONDITION'
This clause stops the loop when the specified condition is true,
i.e., non-`nil'.
`always CONDITION'
This clause stops the loop when the specified condition is `nil'.
Unlike `while', it stops the loop using `return nil' so that the
`finally' clauses are not executed. If all the conditions were
non-`nil', the loop returns `t':
(if (loop for size in size-list always (> size 10))
(some-big-sizes)
(no-big-sizes))
`never CONDITION'
This clause is like `always', except that the loop returns `t' if
any conditions were false, or `nil' otherwise.
`thereis CONDITION'
This clause stops the loop when the specified form is non-`nil';
in this case, it returns that non-`nil' value. If all the values
were `nil', the loop returns `nil'.