result
= match ( fun_handle, iterable )
¶match is filter, like Lisp’s ( & numerous other language’s ) function for Python has a built-in filter function which takes two arguments, a function and a list, and returns a list. ’match’ performs the same operation like filter in Python. The match applies the function to each of the element in the iterable and collects that the result of a function applied to each of the data structure’s elements in turn, and the return values are collected as a list of input arguments, whenever the function-result is ’true’ in Octave sense. Anything (1,true,?) evaluating to true, the argument is saved into the return value.
fun_handle can either be a function name string or a function handle (recommended).
Typically you can use it as,
match(@(x) ( x >= 1 ), [-1 0 1 2]) ⇒ 1 2
See also: reduce, cellfun, arrayfun, cellfun, structfun, spfun.
Package: miscellaneous