Variant: Difference between revisions

From NARS2000
Jump to navigationJump to search
(Created page with "<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> <tr> <td> <table border="0" cellpadding="5" cellspacing="0" summary=""> <tr> <td val...")
 
No edit summary
Line 58: Line 58:


<tr>
<tr>
   <td><apll>L⌷R</apll></td>
   <td><apll>L⌷R</apll>, <apll>L⍉R</apll>, <apll>⍋R</apll>, <apll>L⍋R</apll>, <apll>⍒R</apll>, <apll>L⍒R</apll>, <apll>L⊂R</apll>, <apll>⍸R</apll>, <apll>LπR</apll></td>
   <td><i>N</i></td>
   <td><i>N</i></td>
   <td><apll>⎕IO←<i>N</i></apll>
   <td><apll>⎕IO←<i>N</i></apll>
Line 70: Line 70:


<tr>
<tr>
   <td><apll><apll>L&lt;R</apll>, <apll>L≤R</apll>, <apll>L=R</apll>, <apll>L≥R</apll>, and <apll>L&gt;R</apll></td>
   <td><apll><apll>L&lt;R</apll>, <apll>L≤R</apll>, <apll>L=R</apll>, <apll>L≠R</apll>, <apll>L≥R</apll>, <apll>L&gt;R</apll>,<br />
<apll>L∊R</apll>, <apll>L≡R</apll>, <apll>L≢R</apll>, <apll>L∪R</apll>, <apll>L∩R</apll>,<br />
<apll>L⊆R</apll>, <apll>L⊇R</apll>, <apll>L§R</apll>, <apll>L~R</apll>, <apll>L⍷R</apll>, <apll>L|R</apll><br />
<apll>⌊R</apll>, <apll>⌈R</apll>, <apll>∪R</apll></td>
   <td><i>N</i></td>
   <td><i>N</i></td>
   <td><apll>⎕CT←<i>N</i></apll>
   <td><apll>⎕CT←<i>N</i></apll>

Revision as of 20:28, 24 May 2013

Z←f⍠B R or Z←L f⍠B R evaluates f R or L f R in the context described by B.
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, L⍉R, ⍋R, L⍋R, ⍒R, L⍒R, L⊂R, ⍸R, LπR N ⎕IO←N
⍕R and L⍕R N ⎕PP←N
L<R, L≤R, L=R, L≠R, L≥R, L>R,

L∊R, L≡R, L≢R, L∪R, L∩R,
L⊆R, L⊇R, L§R, L~R, L⍷R, L|R

⌊R, ⌈R, ∪R
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