Iteration



while test {form}* [special]

While test is evaluated to non-nil, forms are evaluated repeatedly. While special form automatically establishes a block by name of nil around forms, and return can be used to exit from the loop.


tagbody {tag $\vert$ statement}* [special]

tags are labels for go. You can use go only in tagbody.


go tag [special]

transfers control to the form just after tag which appears in a lexically scoped tagbody. Go to the tag in a different tagbody across the lexical scope is inhibited.


prog ({var $\vert$ (var [init])}*) {tag $\vert$ statement}* [macro]

prog is a macro, which expands as follows:

 (block nil     (let var (tagbody  tag $\vert$ statement))) 


do ({(var init [next])}*) (endtest [result]){declare} {form} * [macro]

vars are local variables. To each var, init is evaluated in parallel and assigned. Next, endtest is evaluated and if it is true, do returns result (defaulted to NIL). If endtest returns NIL, each form is evaluated sequentially. After the evaluation of forms, next is evaluated and the value is reassigned to each var, and the next iteration starts.


do* ({var init [next]}*) (endtest [result]){declare} {form}* [macro]

do* is same as do except that the evaluation of init and next, and their assignment to var occur sequentially.


dotimes (var count [result]) {forms}* [macro]

evaluates forms count times. count is evaluated only once. In each evaluation, var increments from integer zero to count minus one.


dolist (var list [result]) {forms}* [macro]

Each element of list is sequentially bound to var, and forms are evaluated for each binding. Dolist runs faster than other iteration constructs such as mapcar and recursive functions, since dolist does not have to create a function closure or to apply it, and no new parameter binding is needed.


until condition {forms}* [macro]

evaluates forms until condition holds.


loop {forms}* [macro]

evaluates forms forever. To terminate execution, return-from, throw or go needed to be evaluated in forms.


k-okada 2013-05-21