Skip to content
Turtle Kitty edited this page Aug 9, 2015 · 2 revisions

each

This operator is used to iterate over data structures.

(let (items (range 1 5) total 0)
    (each n items
        (set! total (+ total n))
        total))

-> 15

(let (items (apply vector (range 1 5)) total 0)
    (each n items
        (set! total (+ total n))
        total))

-> 15

(let (items (: x 1 y 2 z 3 u 4 v 5) total 0)
    (each n items
        (set! total (+ total n.val))
        total))

-> 15
Clone this wiki locally