Arc Cross Reference

repeat

[macro] loop start test update body ...

[macro] for var init max body ...

[macro] forlen var seq body ...

[macro] repeat n body ...

Convenience loop constructs.

loop expands to something like this (gensym'd symbols are shown as __rec etc for readability).

  (do start
       ((rfn __rec (__test)
          (if __test
              (do body ... update (__rec test))))
        test)))

for is specialized to iterate over the range of integers. It expands to something like this gensym'd symbols are shown as __rec etc for readability).

  (with (var nil __i init __max (+ max 1))
     (loop (set var __i) (< var __max) (set var (+ var 1))
        body ...))

forlen repeats from var = 0 to var = (- (len seq) 1).

repeat repeats body ... n times.

Beware of side effects! for and repeat won't work well with call/cc (ccc).

Categories:loop,binding