Darwin Help

Back to Index

mselect

Function mselect


Calling Sequence  mselect(fn,obj,[arg2,...])
Parameters
NameTypeDescription

fn the selection function, returns true/false 
obj a composed object (list, set, structure) whose parts will be selected 
arg2 additional arguments that are passed to fn 
Return Type  anything (the result is of the same type as obj)
Synopsis Mselect selects the parts of the second argument and builds a new object of the same type, but only with the parts for which the function fn is true. More precisely, for each i from 1 to length(obj), op(i,obj) will be in the result depending on fn(op(i,obj),arg2..) being true or false. The extra arguments, arg2, ... are passed as additional arguments to fn.

Select is normally used on lists sets or structures.

Examples
> mselect( type, [-1,0,1,1.2], posint );
[1]
> mselect( x -> (x<1), [-1,0,1,1.2] );
[-1, 0]
See also op