left-fold given collection returning accumulator
Parameters
fold collection :integer :string :dictionary :object :inline :block :range
params :null :block
action :block :bytecode
Attributes
with | :literal | use given index |
seed | :any | use specific seed value |
right | | perform right folding |
Returns
Examples
copy
fold 1..10 [x,y]-> x + y
fold 1..10 .seed:1 [x,y][ x * y ]
copy
fold 1..3 [x,y]-> x - y
fold.right 1..3 [x,y]-> x - y
copy
fold.seed:"0" to [:string] 1..5 [x,y] ->
"(" ++ x ++ "+" ++ y ++ ")"
fold.right.seed:"0" to [:string] 1..5 [x,y] ->
"(" ++ x ++ "+" ++ y ++ ")"
copy
fold 1..10 [x y z] [
print [x y z]
x + z - y
]
copy
fold.with:'i 1..5 [x y][
print [i x y]
i * x+y
]
Related