get collection's items by filtering those that do not fulfil given condition
Parameters
filter collection :integer :string :literal :dictionary :object :inline :block :range
params :null :literal :block
condition :block :bytecode
Attributes
with | :literal | use given index |
first | :integer | only filter first element/s |
last | :integer | only filter last element/s |
Returns
Examples
copy
print filter 1..10 [x][
even? x
]
copy
arr: 1..10
filter 'arr 'x -> even? x
print arr
copy
filter [1 1 2 3 5 8 13 21] [x y]-> odd? x+y
copy
filter.with:'i ["zero" "one" "two" "three" "four" "five"] []-> even? i
copy
filter.first 1..10 => odd?
=> [2 3 4 5 6 7 8 9 10]
filter.first:3 1..10 => odd?
=> [2 4 6 7 8 9 10]
copy
filter.last 1..10 => odd?
=> [1 2 3 4 5 6 7 8 10]
filter.last:3 1..10 => odd?
=> [1 2 3 4 6 8 10]
Related