∨∧⍱⍲↑↓
Contents
∨∧⍱⍲↑↓
#
OR, GCD ∨
#
∨
is logical OR, and it is Greatest Common Divisor for for other numbers (which happens to fit with OR for 0s and 1s):
0 1 0 1 ∨ 0 0 1 1 ⍝ logical OR
15 1 2 7 ∨ 35 1 4 0 ⍝ GCD
0 1 1 1
5 1 2 7
AND, LCD ∧
#
∧
is logical AND, and it is Lowest Common Multiple for for other numbers (which happens to fit with AND for 0s and 1s):
0 1 0 1 ∧ 0 0 1 1 ⍝ logical AND
15 1 2 7 ∧ 35 1 4 0 ⍝ LCM
0 0 0 1
105 1 4 0
NOR, NAND ⍱⍲
#
⍱
is NOR, and ⍲
is NAND. They only work on Booleans (arrays with nothing but 1s and 0s). Note that you can use ≠
as XOR and =
as XNOR (and you can use ≤
as logical implication. Similarly for the other comparisons.)
0 1 0 1 ⍱ 0 0 1 1 ⍝ NOR
0 1 0 1 ≠ 0 0 1 1 ⍝ XOR
0 1 0 1 = 0 0 1 1 ⍝ XNOR
0 1 0 1 ⍲ 0 0 1 1 ⍝ NAND
1 0 0 0
0 1 1 0
1 0 0 1
1 1 1 0
Take ↑
#
A↑B
takes from B
. If A
is a scalar/one-element-vector, it takes major cells, if it has two two elements, the first element is the number of major cells, and the second the number of semi-major cells, etc.:
3 4⍴⎕A ⍝ original array
2↑3 4⍴⎕A ⍝ take two major cells (a.k.a rows)
2 3↑3 4⍴⎕A ⍝ two major, and three semi-major cells
ABCD EFGH IJKL
ABCD EFGH
ABC EFG
If you take more than there is, ↑
will pad with 0s for numeric arguments, and spaces for character arguments:
6↑3 1 4
3 1 4 0 0 0
You may also “overtake” a scalar to any number of dimensions:
2 3↑4
4 0 0 0 0 0
Negative numbers indicate taking from the reverse:
¯6↑3 1 4
¯2 ¯3↑4
0 0 0 3 1 4
0 0 0 0 0 4
3 4⍴⎕A
¯2 ¯2↑3 4⍴⎕A
ABCD EFGH IJKL
GH KL
Mix ↑
#
Monadic ↑
is mix. It trades one level of depth (nesting) into one level of rank.
↑(1 2 3)(4 5 6)
1 2 3 4 5 6
Because rank enforces non-raggedness, monadic ↑
will pad with the prototype element (0 or space) just like dyadic ↑
:
↑(1 2 3)(4 5)
1 2 3 4 5 0
Drop ↓
#
Dyadic ↓
is just like dyadic ↑
except it drops instead of taking:
3 4⍴⎕A
1↓3 4⍴⎕A
]display 2 1↓3 4⍴⎕A
ABCD EFGH IJKL
EFGH IJKL
┌→──┐ ↓JKL│ └───┘
Note that the last result is still a matrix, it just only has one row.
Split ↓
#
Monadic ↓
is split. It is the opposite of dyadic ↓
in that it lowers the rank and increases the depth:
↓3 4⍴⎕A
┌────┬────┬────┐ │ABCD│EFGH│IJKL│ └────┴────┴────┘