do Construct

Lisp provides a do construct for more general loops. The format of a do statement is:

(do ( varspecs )
( endtest results )
statement_1 ... statement_n )

Each varspec is a list of the form: ( var init step )

The do is executed in the following way:

  1. Each var is initialized to its init value.

  2. The endtest is evaluated. If it is true (not #f), then the results are executed in order. The value of the do is the value of the last result.

  3. Otherwise, when the endtest is #f, the statements are executed in order. Then the step expression for each var is evaluated, the var is bound to that value, and the loop is repeated.

Contents    Page-10    Prev    Next    Page+10    Index