loop
loop {compound-form}* → {result}*
loop [↓name-clause] {↓variable-clause}* {↓main-clause}* → {result}*
named namecollect | collecting | append | appending | nconc | nconcing} {form | it} into simple-var]count | counting | sum | summing | maximize | maximizing | minimize | minimizing} {form | it} into simple-var] [type-spec]if | when | unless} form ↓selectable-clause {and ↓selectable-clause}* else ↓selectable-clause {and ↓selectable-clause}*] end]while form | until form | repeat form | always form | never form | thereis formthen form2]across vectorbeing {each | the} hash-key | hash-keys} {in | of} hash-table using (hash-value other-var)] | hash-value | hash-values} {in | of} hash-table using (hash-key other-var)]}being {each | the} symbol | symbols |present-symbol | present-symbols |external-symbol | external-symbols} in | of} package]of-type d-type-spec(d-type-spec . d-type-spec)nil | (↓d-var-spec . ↓d-var-spec)
compound-form—a compound form.
name—a symbol.
Per X3J13. -kmp 05-Oct-93 \param{var}, \param{var1}, \param{var2}, \param{other-var}---a \term{symbol} (a \term{variable} \term{name}).simple-var—a symbol (a variable name).
form, form1, form2, form3—a form.
step-fun—a form that evaluates to a function of one argument.
vector—a form that evaluates to a vector.
hash-table—a form that evaluates to a hash table.
package—a form that evaluates to a package designator.
type-specifier—a type specifier. This might be either an atomic type specifier or a compound type specifier, which introduces some additional complications to proper parsing in the face of destructuring; for further information, see Section 6.1.1.7 (Destructuring).
result—an object.
!!! This should be elaborated slightly here.For details, see Section 6.1 (The LOOP Facility).
;; An example of the simple form of LOOP. (defun sqrt-advisor () (loop (format t "~&Number: ") (let ((n (parse-integer (read-line) :junk-allowed t))) (when (not n) (return)) (format t "~&The square root of ~D is ~D.~%" n (sqrt n))))) → SQRT-ADVISOR (sqrt-advisor) ⊳ Number: 5↩ ⊳ The square root of 5 is 2.236068. ⊳ Number: 4↩ ⊳ The square root of 4 is 2. ⊳ Number: done↩ → NIL ;; An example of the extended form of LOOP. (defun square-advisor () (loop as n = (progn (format t "~&Number: ") (parse-integer (read-line) :junk-allowed t)) while n do (format t "~&The square of ~D is ~D.~%" n (* n n)))) → SQUARE-ADVISOR (square-advisor) ⊳ Number: 4↩ ⊳ The square of 4 is 16. ⊳ Number: 23↩ ⊳ The square of 23 is 529. ⊳ Number: done↩ → NIL ;; Another example of the extended form of LOOP. (loop for n from 1 to 10 when (oddp n) collect n) → (1 3 5 7 9)
None.
None.
do, dolist, dotimes, return, go, throw, Section 6.1.1.7 (Destructuring)
Per X3J13. -kmp 05-Oct-93
The simple form of \macref{loop} is related to the extended form
in the following way:Except that loop-finish cannot be used within a simple loop form, a simple loop form is related to an extended loop form in the following way:
(loop {compound-form}*) ≡ (loop do {compound-form}*)