get collection's items that fulfil given condition
Parameters
select 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 return first element/s |
last | :integer | only return last element/s |
n | :integer | only return n-th element |
Returns
Examples
copy
print select 1..10 [x][
even? x
]
; 2 4 6 8 10
copy
arr: 1..10
select 'arr 'x -> even? x
print arr
; 2 4 6 8 10
copy
select [1 1 2 3 5 8 13 21] [x y]-> odd? x+y
; => [2 3 5 8]
copy
select.with:'i ["zero" "one" "two" "three" "four" "five"] []-> even? i
; => ["zero" "two" "four"]
copy
select.first 1..10 => odd?
=> [1]
select.first:3 1..10 => odd?
=> [1 3 5]
copy
select.last 1..10 => odd?
=> [9]
select.last:3 1..10 => odd?
=> [5 7 9]
Related