Variant
|
||||
L and R are arbitrary arrays conformable with f, and B is a simple scalar or nested vector. | ||||
f is a function. |
The dyadic Variant operator creates a version of the function f with a set of properties bound to it as specified by the array right operand. For example, ⍳⍠0 is a version of ⍳ that executes in origin-0 independent of the current value of ⎕IO.
The array right operand to the operator may take several different forms depending upon the function left operand. In the general case, for any kind of function left operand, the right operand may specify a single property in the form of Key Val, or multiple properties in the form of (Key1 Val1) (Key2 Val2) ..., or if the left operand is a primitive function, a shorthand notation may be used as in Val or Val1 Val2.
In the general case, the keys specify a property such as Index Origin as 'IO' or Comparison Tolerance as 'CT', and the value part specifies a value appropriate to the property specified in the matching key. At the moment, the keys that may be used are 'CT', 'DT', 'IO', and 'PP' which stand for the corresponding system variable.
For example:
1 2 (3+1e¯9) 3⍳⍠(('IO' 0) ('CT' 1e¯10)) 3
3
1 2 (3+1e¯10) 3⍳⍠(('IO' 0) ('CT' 1e¯10)) 3
2
⍳⍠('IO' 0) 3
0 1 2
⍳⍠('IO' 1) 3
1 2 3
⍳⍠('IO' 0) ⍠('IO' 1) 3
0 1 2
⍳⍠('IO' 1) ⍠('IO' 0) 3
1 2 3
Note that in the last two examples, the lefthand (innermost) value of ⎕IO takes precedence.
If the left operand is a primitive function, the following shorthands may be used:
⍳R and L⍳R | N | ⎕IO←N |
N1 N2 | ⎕IO←N1 and ⎕CT←N2 | |
L⌷R | N | ⎕IO←N |
⍕R and L⍕R | N | ⎕PP←N |
N | ⎕CT←N | |
?R and L?R | N | ⎕IO←N |
C | ⎕DT←C | |
N C | ⎕IO←N and ⎕DT←C | |
C N | ⎕IO←N and ⎕DT←C |