From ftm
Jump to: navigation, search
Line 16: Line 16:
 
finds values greater or equal 1 in the first 20 indices and replaces $myfmat with
 
finds values greater or equal 1 in the first 20 indices and replaces $myfmat with
 
their indices.
 
their indices.
 +
 +
[[Category:FAQ]] [[Category:FTM Documentation]] [[Category:fmat Class]] [[Category:expr Class]] [[Category:ftm.mess]]

Revision as of 14:22, 2 July 2010

This is a method of the fmat class.

Syntax: 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 or equal 1 in the first 20 indices and replaces $myfmat with their indices.