Line 1: | Line 1: | ||
− | + | find <expr: expression> <any: arguments to expression...> | |
− | where expression is true (use $x, $i and $self) | + | |
+ | - leave indices where expression is true (use $x, $i and $self) | ||
The find method of fmat replaces an fmat with the (unwrapped) indices of the | The find method of fmat replaces an fmat with the (unwrapped) indices of the |
Revision as of 09:42, 5 May 2009
find <expr: expression> <any: arguments to expression...>
- leave indices where expression is true (use $x, $i and $self)
The find method of fmat replaces an fmat with the (unwrapped) indices of the elements for which the given expression returned non-zero. The expression can use the arguments to the find method following the expression as $1, $2, etc., and the predefined super-local variables $x (the value of the element being tested), $i (its index), and $self (the reference to the fmat itself). Otherwise, only global definitions are visible within the expression. (The latter holds for any expression evaluation.)
Example: ($myfmat find $myexpr 1 20) with myexpr = '(($x >= $1) && ($i < $2))' finds values greater than 1 in the first 20 indices and replaces $myfmat with their indices.