From ftm
Jump to: navigation, search
Line 1: Line 1:
find <expr: expression> <any: arguments to expression...>  
+
This is a method of the [[FTM_Classes#Class_fmat| fmat class]].
 +
 
 +
Syntax: <code>find <expr: expression> <any: arguments to expression...> </code>
  
 
- leave indices where expression is true (use $x, $i and $self)
 
- leave indices where expression is true (use $x, $i and $self)
Line 11: Line 13:
 
latter holds for any expression evaluation.)
 
latter holds for any expression evaluation.)
  
Example: ($myfmat find $myexpr 1 20) with myexpr = '(($x >= $1) && ($i < $2))'
+
Example: <code>($myfmat find $myexpr 1 20)</code> with myexpr = '(($x >= $1) && ($i < $2))'
finds values greater than 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.

Revision as of 11:10, 15 December 2009

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.