select

select(v,f) -- select elements of the list or hash table v which yield true when the function f is applied.
select(n,v,f) -- select at most n elements of the list or hash table v which yield true when the function f is applied.

For a list, the order of the elements in the result will be the same as in the original list v.

For a hash table, the function is applied to each value. This may change, for perhaps it should be applied to the key/value pair. The hash table should be immutable: to scan the values in a mutable hash table, use scan(values x, f).

i1 : select({1,2,3,4,5}, odd)

o1 = {1, 3, 5}

o1 : List
i2 : select(2,{1,2,3,4,5}, odd)

o2 = {1, 3}

o2 : List

See also scan, apply, any, all, member, and mutable.


topindexpreviousupnext