chickadee » anaphora » awhile

(awhile test xpr . xprs)syntax

Anaphoric version of while.

The body xpr . xprs is evaluated as often, as the test is true. As usual, the result of this test, which often is the result of a poll operation, is named it and can be referenced in the body.

(let ((lst '(1 2 3 4 5 #f)) (res '()))
  (awhile (car lst)
    (set! res (cons (car lst) res))
    (set! lst (cdr lst)))
  res)

Of course, this is not the preferred programming style in Scheme ...