Filter()

From TinyMUX
Jump to navigation Jump to search

FILTER()

 FUNCTION: filter([<obj>/]<attr>, <list>[, <in delim>[, <out delim>[,<arg1>[,<arg2>[,...]]]]])
 This function evaluates the contents of <attr> for each element of <list>,
 passing it in as %0.  A <out delim>-separated list is returned of those
 elements for which the evaluation returns the value 1.  Arguments %1, %2,
 ... are taken from <arg1>, <arg2>, ... respectively, if present.
 <in delim> may be used to specify an input delimiter other than space.
 Examples:
   > &IS_ODD object=mod(%0,2)
   > say filter(object/is_odd,1 2 3 4 5)
   You say, "1 3 5"
 Related Topics: u(), map(), fold()