loop

Loops through an array and evaluates the expr in a lexical context

(loop var? in array expr*)

Description

Loops through an array and evaluates the expr in a lexical context. If var is missing you can access the value using `_value`

Body

var - the name of the variable

array - the array to loop

expr* - expressions to be evaluated

Examples

(loop var1 in [1, 2, 3, 4]
    (print var1)
)
;;=> 1, 2, 3, 4

(loop [1, 2, 3, 4]
    (str _value ":" _index)
)

(def names ["John", "Bob", "Marry"])
(loop name in names
    (str "Hello" name)
)
;;=> Hello John
;;=> Hello Bob
;;=> Hello Marry

Was this helpful?