loop through collection, using given iterator and block
Parameters
loop collection :integer :string :dictionary :object :inline :block :range
params :null :literal :block
action :block :bytecode
Attributes
with | :literal | use given index |
forever | | cycle through collection infinitely |
Returns
Examples
copy
loop [1 2 3] 'x [
print x
]
; 1
; 2
; 3
copy
loop 1..3 [x][
print ["x =>" x]
]
; x => 1
; x => 2
; x => 3
copy
loop [A a B b C c] [x y][
print [x "=>" y]
]
; A => a
; B => b
; C => c
copy
user: #[
name: "John"
surname: "Doe"
]
loop user [k v][
print [k "=>" v]
]
; name => John
; surname => Doe
copy
loop.with:'i ["zero" "one" "two"] 'x [
print ["item at:" i "=>" x]
]
; 0 => zero
; 1 => one
; 2 => two
copy
loop.forever [1 2 3] => print
; 1 2 3 1 2 3 1 2 3 ...
Related