Name

foreach

Usage

macro

Syntax

(foreach (sym seq) &body forms)

Description

Executes forms repeatedly. Uses loop.

user 1 > (foreach (x (series 1 5)) (collecting (+ x x)))
it: #v(2 4 6 8 10)
user 2 > (macroexpand-1 '(foreach (x y) a b c))
it: ((loop (for x :in y) a b c) true)
user 3 > (macroexpand '(foreach (x y) a b c))
it: (do
        (let %range-x (system:get-safe-enumerator y))
        (var x null)
        (label test-label)
        (do
            (if (not (ienumerator:move-next %range-x))
                (goto finish-label))
            (setf x (ienumerator:current %range-x))
            x)
        (do
            a
            b
            c)
        (goto test-label)
        (label finish-label))