Skip to content
TurtleKitty edited this page May 11, 2019 · 2 revisions

loop

loop is a general looping construct. The loop is given a label that is defined only in the loop's environment; calling this label like a procedure causes the loop to execute again.

(def things '(2 3 5))

(loop repeat (x things.head xs things.tail acc ())
   (def new-acc (acc.cons (* x x)))
   (if xs
      (repeat xs.head xs.tail new-acc)
      new-acc))

; (25 9 4)
Clone this wiki locally