Symbol Reduce: Difference between revisions
No edit summary |
(→Reduce) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<h1> {compress} — Reduce/compress/replicate Operator — Keystroke / — Character 93 or x5D</h1> | |||
<h1> {compress} — Reduce Operator — Keystroke | Note: The APL name of this symbol is <big>compress</big> or '''{compress}''', not '''reduce''', however, reduce or reduction is the usual name for this symbol, but compress is one of the functions. | ||
Note: The APL name of this symbol is <big>compress</big> or '''{compress}''', not '''reduce'''. | |||
This symbol performs several different operations depending on whether it is combined with certain other operators | |||
=Functions= | |||
*L / R compress or replicate R according to value in L | |||
* f/ R reduce operator f on each argument in R | |||
==Compress / Replicate== | |||
The argument on the left selects the elements on the right to discard, keep, or copy. For each element on the right there is a numeric value on the left indicating how many copies of that element on the right to keep. The number of elements must match. If the number is 0, that element is dropped. If 1, it is kept. If >1, it is copied that many times. | |||
===Usage=== | |||
<code> | |||
1 1 0 0 0 0 0 0 0 0 0 0 1 1 / 'Taste the cake'<br/> | |||
Take<br/> | |||
2 1 0 0 0 0 0 0 0 0 0 0 1 1 / 'Taste the cake'<br/> | |||
TTake<br/> | |||
1 1 1 0 / 'take' 'this' 'drop' 'that'<br/> | |||
take this drop<br/> | |||
1 1 1 1 / 'take' 'this' 'drop' 'that'<br/> | |||
take this drop that<br/> | |||
1 0 1 1 / 'take' 'this' 'drop' 'that'<br/> | |||
take drop that<br/> | |||
0 1 1 0 / 'take' 'this' 'drop' 'that'<br/> | |||
this drop<br/> | |||
1 0 0 1 1/ 1 2 3 4 5<br/> | |||
1 4 5<br/> | |||
1 2 3 4 5 / 1 2 3 4 5<br/> | |||
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5<br/> | |||
</code> | |||
==Reduce== | |||
The operator to the left of the reduce operator is applied to the values to the right. These operators include | |||
* !/ Factorial reduce | |||
* -/ Minus reduce | |||
* +/ Plus reduce | |||
* ×/ Times reduce | |||
* */ Star reduce | |||
* ⍟/ Log reduce | |||
* ○/ Jot reduce | |||
* ∨/ Or reduce | |||
* ∧/ And reduce | |||
* ⍱/ Nor reduce | |||
* ⍲/ Nand reduce | |||
* ⌈/ Maximum | |||
* ⌊/ Minimum | |||
* =/ Binary operators | |||
* ≠/ | |||
* ≤/ | |||
* </ | |||
* >/ | |||
* ≥/ | |||
==Usage== | ==Usage== | ||
==Example== | ==Example== | ||
==See Also== | ==See Also== |
Latest revision as of 02:30, 13 March 2013
/ — Reduce/compress/replicate Operator — Keystroke / — Character 93 or x5D
Note: The APL name of this symbol is compress or {compress}, not reduce, however, reduce or reduction is the usual name for this symbol, but compress is one of the functions.
This symbol performs several different operations depending on whether it is combined with certain other operators
Functions
- L / R compress or replicate R according to value in L
- f/ R reduce operator f on each argument in R
Compress / Replicate
The argument on the left selects the elements on the right to discard, keep, or copy. For each element on the right there is a numeric value on the left indicating how many copies of that element on the right to keep. The number of elements must match. If the number is 0, that element is dropped. If 1, it is kept. If >1, it is copied that many times.
Usage
1 1 0 0 0 0 0 0 0 0 0 0 1 1 / 'Taste the cake'
Take
2 1 0 0 0 0 0 0 0 0 0 0 1 1 / 'Taste the cake'
TTake
1 1 1 0 / 'take' 'this' 'drop' 'that'
take this drop
1 1 1 1 / 'take' 'this' 'drop' 'that'
take this drop that
1 0 1 1 / 'take' 'this' 'drop' 'that'
take drop that
0 1 1 0 / 'take' 'this' 'drop' 'that'
this drop
1 0 0 1 1/ 1 2 3 4 5
1 4 5
1 2 3 4 5 / 1 2 3 4 5
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Reduce
The operator to the left of the reduce operator is applied to the values to the right. These operators include
- !/ Factorial reduce
- -/ Minus reduce
- +/ Plus reduce
- ×/ Times reduce
- */ Star reduce
- ⍟/ Log reduce
- ○/ Jot reduce
- ∨/ Or reduce
- ∧/ And reduce
- ⍱/ Nor reduce
- ⍲/ Nand reduce
- ⌈/ Maximum
- ⌊/ Minimum
- =/ Binary operators
- ≠/
- ≤/
- </
- >/
- ≥/
Usage
Example
See Also
NARS 2000 Lang Tool Bar |
← | → | + | - | × | ÷ | * | ⍟ | ⌹ | ○ | ! | ? | √ | | | ⌈ | ⌊ | ⊥ | ⊤ | ⊣ | ⊢ | |||
≡ | ≢ | < | ≤ | = | ≥ | > | ≠ | ∨ | ∧ | ⍱ | ⍲ | ↑ | ↓ | ⊂ | ⊃ | ⌷ | ⍋ | ⍒ | |||||
⍳ | ∊ | ⍸ | ⍷ | ∪ | ∩ | ⊆ | ⊇ | ~ | § | π | .. | , | ⍪ | ⍴ | ⌽ | ⊖ | ⍉ | ||||||
/ | \ | ⌿ | ⍀ | ⊙ | ¨ | ⍨ | ⍤ | ⍣ | ⍡ | ⍥ | ⍦ | . | ∘ | ⍠ | ‼ | ⌻ | ∂ | ∫ | ⍞ | ⎕ | ⍎ | ⍕ | |
⋄ | ⍝ | ∇ | ∆ | ⍙ | _ | ⍺ | ⍵ | ¯ | ⍬ | ∞ | ∅ | ||||||||||||
Second Row | i j k | i j k l | g | p | r | v | x |