Arc Cross Reference

drain

[macro] drain expr (o eof nil)

Evaluates expr repeatedly until it yields the value eof, then returns a list of results. Call/cc unsafe.

(mac drain (expr (o eof nil))
  (w/uniq (gacc gdone gres)
    `(with (,gacc nil ,gdone nil)
       (while (no ,gdone)
         (let ,gres ,expr
           (if (is ,gres ,eof)
               (= ,gdone t)
               (push ,gres ,gacc))))
       (rev ,gacc))))

Categorys:loop