Variant: Difference between revisions
(add toolbar footer) |
No edit summary |
||
Line 13: | Line 13: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><apll>L</apll> and <apll>R</apll> are arbitrary arrays conformable with <apll>f</apll>, and <apll>B</apll> is a simple scalar or nested vector.</td> | <td><apll>L</apll> and <apll>R</apll> are arbitrary arrays conformable with <apll>f</apll>, and <apll>B</apll> is a simple scalar, simple or heterogeneous vector, or nested vector.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
Line 97: | Line 97: | ||
<td><i>C N</i> | <td><i>C N</i> | ||
<td><apll>⎕IO←<i>N</i></apll> and <apll>⎕DT←<i>C</i></apll></td> | <td><apll>⎕IO←<i>N</i></apll> and <apll>⎕DT←<i>C</i></apll></td> | ||
</tr> | |||
<tr> | |||
<td rowspan="2"><apll>!R</apll> ([https://en.wikipedia.org/wiki/Pochhammer_k-symbol Pochhammer k-symbol])</td> | |||
<td><i>N</i></td> | |||
<td>Rising (<i>N</i> > 0) and Falling (<i>N</i> < 0) factorial of length <apll>|</apll><i>N</i>, stepping by <apll>|</apll><i>N</i> in the direction of <i>N</i></td> | |||
</tr> | |||
<tr> | |||
<td><i>N1 N2</i></td> | |||
<td>Rising (<i>N1</i> > 0) and Falling (<i>N1</i> < 0) factorial of length <apll>|</apll><i>N1</i>, stepping by <apll>|</apll><i>N2</i> in the direction of <i>N1</i></td> | |||
</tr> | </tr> | ||
</table> | </table> | ||
<br /> | |||
<h2>Rising and Falling Factorials</h2> | |||
<p>A falling factorial is like the normal factorial except that it subtracts the step value (<apll>1</apll>) from the original number after a fixed # of iterations. That is, <apll>!6</apll> successively decrements <apll>1</apll> from <apll>6</apll> and multiplies the numbers <apll>6 5 4 3 2 1</apll> to get <apll>720</apll>. A falling factorial starting with <apll>6</apll> of length (say) <apll>3</apll> multiplies <apll>6 5 4</apll> to get <apll>120</apll>. | |||
</p> | |||
<p>A rising factorial is like a falling factorial except it adds the step value (<apll>1</apll>) instead of subtracting it. A rising factorial starting with <apll>6</apll> of length (say) <apll>3</apll> multiplies <apll>6 7 8</apll> to get <apll>336</apll>. | |||
</p> | |||
<p>Here are some examples of the falling factorial</p> | |||
<apll> | |||
!6<br /> | |||
720<br /> | |||
(!⍠¯6)6 ⍝ ×/6 5 4 3 2 1<br /> | |||
720<br /> | |||
(!⍠¯5)6 ⍝ ×/6 5 4 3 2<br /> | |||
720<br /> | |||
(!⍠¯4)6 ⍝ ×/6 5 4 3<br /> | |||
360<br /> | |||
(!⍠¯3)6 ⍝ ×/6 5 4<br /> | |||
120<br /> | |||
(!⍠¯2)6 ⍝ ×/6 5<br /> | |||
30<br /> | |||
(!⍠¯1)6 ⍝ ×/6<br /> | |||
6<br /> | |||
(!⍠¯0)6 ⍝ ×/⍬<br /> | |||
1<br /> | |||
</apll> | |||
<p>and now falling by <apll>2</apll></p> | |||
<apll> | |||
(!⍠¯6 2)6 ⍝ ×/6 4 2 0 ¯2 ¯4<br /> | |||
0<br /> | |||
(!⍠¯5 2)6 ⍝ ×/6 4 2 0 ¯2<br /> | |||
0<br /> | |||
(!⍠¯4 2)6 ⍝ ×/6 4 2 0<br /> | |||
0<br /> | |||
(!⍠¯3 2)6 ⍝ ×/6 4 2<br /> | |||
48<br /> | |||
(!⍠¯2 2)6 ⍝ ×/6 4<br /> | |||
24<br /> | |||
(!⍠¯1 2)6 ⍝ ×/6<br /> | |||
6<br /> | |||
(!⍠¯0 2)6 ⍝ ×/⍬<br /> | |||
1<br /> | |||
</apll> | |||
<p>and here are some examples of the rising factorial</p> | |||
<apll> | |||
(!⍠6)6 ⍝ ×/6 7 8 9 10 11<br /> | |||
332640<br /> | |||
(!⍠5)6 ⍝ ×/6 7 8 9 10<br /> | |||
30240<br /> | |||
(!⍠4)6 ⍝ ×/6 7 8 9<br /> | |||
3024<br /> | |||
(!⍠3)6 ⍝ ×/6 7 8<br /> | |||
336<br /> | |||
(!⍠2)6 ⍝ ×/6 7<br /> | |||
42<br /> | |||
(!⍠1)6 ⍝ ×/6<br /> | |||
6<br /> | |||
(!⍠0)6 ⍝ ×/⍬<br /> | |||
1<br /> | |||
</apll> | |||
<p>and now rising by <apll>2</apll></p> | |||
<apll> | |||
(!⍠6 2)6 ⍝ ×/6 8 10 12 14 16<br /> | |||
1290240<br /> | |||
(!⍠5 2)6 ⍝ ×/6 8 10 12 14<br /> | |||
80640<br /> | |||
(!⍠4 2)6 ⍝ ×/6 8 10 12<br /> | |||
5760<br /> | |||
(!⍠3 2)6 ⍝ ×/6 8 10<br /> | |||
480<br /> | |||
(!⍠2 2)6 ⍝ ×/6 8<br /> | |||
48<br /> | |||
(!⍠1 2)6 ⍝ ×/6<br /> | |||
6<br /> | |||
(!⍠0 2)6 ⍝ ×/⍬<br /> | |||
1<br /> | |||
</apll> | |||
<h2>Identities</h2> | |||
<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | |||
<tr> | |||
<td><apll>(!⍠N)R</apll></td> | |||
<td><apll> ←→ </apll></td> | |||
<td><apll>(!⍠(N 1))R</apll></td> | |||
</tr> | |||
<tr> | |||
<td><apll>(!⍠(N 0))R</apll></td> | |||
<td><apll> ←→ </apll></td> | |||
<td><apll>R*N</apll></td> | |||
</tr> | |||
</table> | |||
{{Language Toolbar}} | {{Language Toolbar}} |
Revision as of 20:50, 27 August 2016
|
||||
L and R are arbitrary arrays conformable with f, and B is a simple scalar, simple or heterogeneous vector, 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, |
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 | |
!R (Pochhammer k-symbol) | N | Rising (N > 0) and Falling (N < 0) factorial of length |N, stepping by |N in the direction of N |
N1 N2 | Rising (N1 > 0) and Falling (N1 < 0) factorial of length |N1, stepping by |N2 in the direction of N1 |
Rising and Falling Factorials
A falling factorial is like the normal factorial except that it subtracts the step value (1) from the original number after a fixed # of iterations. That is, !6 successively decrements 1 from 6 and multiplies the numbers 6 5 4 3 2 1 to get 720. A falling factorial starting with 6 of length (say) 3 multiplies 6 5 4 to get 120.
A rising factorial is like a falling factorial except it adds the step value (1) instead of subtracting it. A rising factorial starting with 6 of length (say) 3 multiplies 6 7 8 to get 336.
Here are some examples of the falling factorial
!6
720
(!⍠¯6)6 ⍝ ×/6 5 4 3 2 1
720
(!⍠¯5)6 ⍝ ×/6 5 4 3 2
720
(!⍠¯4)6 ⍝ ×/6 5 4 3
360
(!⍠¯3)6 ⍝ ×/6 5 4
120
(!⍠¯2)6 ⍝ ×/6 5
30
(!⍠¯1)6 ⍝ ×/6
6
(!⍠¯0)6 ⍝ ×/⍬
1
and now falling by 2
(!⍠¯6 2)6 ⍝ ×/6 4 2 0 ¯2 ¯4
0
(!⍠¯5 2)6 ⍝ ×/6 4 2 0 ¯2
0
(!⍠¯4 2)6 ⍝ ×/6 4 2 0
0
(!⍠¯3 2)6 ⍝ ×/6 4 2
48
(!⍠¯2 2)6 ⍝ ×/6 4
24
(!⍠¯1 2)6 ⍝ ×/6
6
(!⍠¯0 2)6 ⍝ ×/⍬
1
and here are some examples of the rising factorial
(!⍠6)6 ⍝ ×/6 7 8 9 10 11
332640
(!⍠5)6 ⍝ ×/6 7 8 9 10
30240
(!⍠4)6 ⍝ ×/6 7 8 9
3024
(!⍠3)6 ⍝ ×/6 7 8
336
(!⍠2)6 ⍝ ×/6 7
42
(!⍠1)6 ⍝ ×/6
6
(!⍠0)6 ⍝ ×/⍬
1
and now rising by 2
(!⍠6 2)6 ⍝ ×/6 8 10 12 14 16
1290240
(!⍠5 2)6 ⍝ ×/6 8 10 12 14
80640
(!⍠4 2)6 ⍝ ×/6 8 10 12
5760
(!⍠3 2)6 ⍝ ×/6 8 10
480
(!⍠2 2)6 ⍝ ×/6 8
48
(!⍠1 2)6 ⍝ ×/6
6
(!⍠0 2)6 ⍝ ×/⍬
1
Identities
(!⍠N)R | ←→ | (!⍠(N 1))R |
(!⍠(N 0))R | ←→ | R*N |
NARS 2000 Lang Tool Bar |
← | → | + | - | × | ÷ | * | ⍟ | ⌹ | ○ | ! | ? | √ | | | ⌈ | ⌊ | ⊥ | ⊤ | ⊣ | ⊢ | |||
≡ | ≢ | < | ≤ | = | ≥ | > | ≠ | ∨ | ∧ | ⍱ | ⍲ | ↑ | ↓ | ⊂ | ⊃ | ⌷ | ⍋ | ⍒ | |||||
⍳ | ∊ | ⍸ | ⍷ | ∪ | ∩ | ⊆ | ⊇ | ~ | § | π | .. | , | ⍪ | ⍴ | ⌽ | ⊖ | ⍉ | ||||||
/ | \ | ⌿ | ⍀ | ⊙ | ¨ | ⍨ | ⍤ | ⍣ | ⍡ | ⍥ | ⍦ | . | ∘ | ⍠ | ‼ | ⌻ | ∂ | ∫ | ⍞ | ⎕ | ⍎ | ⍕ | |
⋄ | ⍝ | ∇ | ∆ | ⍙ | _ | ⍺ | ⍵ | ¯ | ⍬ | ∞ | ∅ | ||||||||||||
Second Row | i j k | i j k l | g | p | r | v | x |