The rest of the glyphs

Dyalog
APL
Glyphs
Author

Jeremy Howard

Published

July 5, 2022

]box on -style=max -trains=tree -fns=on
┌→─────────────────────────────────────┐
│Was ON -style=max -trains=tree -fns=on│
└──────────────────────────────────────┘

Sets and stuff

(Epsilon)

monadic (Enlist)

⎕←mat←2 3⍴⍳6
┌→────┐
↓1 2 3│
│4 5 6│
└~────┘
∊ 0 mat (7 8) 'nine'
┌→─────────────────────┐
│0 1 2 3 4 5 6 7 8 nine│
└+─────────────────────┘

dyadic (Member of)

'abc' 4 ∊ 4 'ab' 'abcd'
┌→──┐
│0 1│
└~──┘
mat←2 3⍴⍳6
mat ∊ 6 2 7 4
┌→────┐
↓0 1 0│
│1 0 1│
└~────┘

(Epsilon Underbar)

dyadic (Find)

1 ⍷ 3 1 4 1 5 9 2
┌→────────────┐
│0 1 0 1 0 0 0│
└~────────────┘
1 4 ⍷ 3 1 4 1 5 9 2
┌→────────────┐
│0 1 0 0 0 0 0│
└~────────────┘
'ana' ⍷ 'Banana'
┌→──────────┐
│0 1 0 1 0 0│
└~──────────┘
X ← 2 2 ⍴ 0 1 1 0
Y ← 4 4 ⍴ 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0
X Y
┌→────────────────┐
│ ┌→──┐ ┌→──────┐ │
│ ↓0 1│ ↓0 1 0 0│ │
│ │1 0│ │1 0 0 1│ │
│ └~──┘ │0 0 1 0│ │
│       │0 1 0 0│ │
│       └~──────┘ │
└∊────────────────┘
X ⍷ Y
┌→──────┐
↓1 0 0 0│
│0 0 1 0│
│0 1 0 0│
│0 0 0 0│
└~──────┘

(Up shoe)

dyadic (Intersection)

'ABRA'∩'CAR'
┌→──┐
│ARA│
└───┘
22 'ab' 'fg' ∩ 'a' 'ab' 22
┌→────────┐
│    ┌→─┐ │
│ 22 │ab│ │
│    └──┘ │
└∊────────┘

(Down shoe)

monadic (Unique)

a ← 2 3 4 2 3 4 5
∪a
┌→──────┐
│2 3 4 5│
└~──────┘
(≠a)/a
┌→──────┐
│2 3 4 5│
└~──────┘
∪ 'ab' 'ba' 'ab' 1 1 2
┌→──────────────┐
│ ┌→─┐ ┌→─┐     │
│ │ab│ │ba│ 1 2 │
│ └──┘ └──┘     │
└∊──────────────┘

dyadic (Union)

'ABRA'∪'CAR'
┌→────┐
│ABRAC│
└─────┘
22 'ab' 'fg' ∪ 'a' 'ab' 22
┌→───────────────┐
│    ┌→─┐ ┌→─┐   │
│ 22 │ab│ │fg│ a │
│    └──┘ └──┘ - │
└∊───────────────┘

Sort / index

(Squad)

monadic (Materialise)

For ⌷ ⍵: If ⍵ is an array, returns ⍵. For a class/COM/.Net object, it materialises the items.

dyadic (Index)

v ← 2×⍳12
3⌷v
 
6
 
(⊂3 5) ⌷v
┌→───┐
│6 10│
└~───┘
⎕ ← mat ← 3 4 ⍴⍳12
┌→─────────┐
↓1  2  3  4│
│5  6  7  8│
│9 10 11 12│
└~─────────┘
2 3 ⌷ mat
 
7
 

(Grade Down)

monadic (Grade Down)

⍒ 33 11 44 66 22
┌→────────┐
│4 3 1 5 2│
└~────────┘
a ← 33 11 44 66 22
a[⍒a]
┌→─────────────┐
│66 44 33 22 11│
└~─────────────┘
a⌷⍨⊂⍒a
┌→─────────────┐
│66 44 33 22 11│
└~─────────────┘

{⍵[⍋⍵]} and {(⊂⍋⍵)⌷⍵} are sort idioms (special cased for performance)

sort ← ⌷⍨∘⊂∘⍒⍨
sort a
┌→─────────────┐
│66 44 33 22 11│
└~─────────────┘
tsort ← (⊂∘⍒)⌷⊢  ⍝ h/t Rory Kemp
tsort a
┌→─────────────┐
│66 44 33 22 11│
└~─────────────┘

dyadic (Dyadic Grade Down)

a ← 'abcdefgabcdefg'
b ← 'cgf' ⍒ a
a⌷⍨⊂b
┌→─────────────┐
│abdeabdeffggcc│
└──────────────┘

(Grade Up)

monadic (Grade Up)

⍋ 33 11 44 66 22
┌→────────┐
│2 5 1 3 4│
└~────────┘
a ← 33 11 44 66 22
a[⍋a]
┌→─────────────┐
│11 22 33 44 66│
└~─────────────┘
a⌷⍨⊂⍋a
┌→─────────────┐
│11 22 33 44 66│
└~─────────────┘

dyadic (Dyadic Grade Down)

a ← 'abcdefgabcdefg'
b ← 'cgf' ⍋ a
a⌷⍨⊂b
┌→─────────────┐
│ccggffabdeabde│
└──────────────┘

Rotate / transpose / flip

(Circle Stile)

monadic (Reverse)

⌽ 'trams'
┌→────┐
│smart│
└─────┘
⎕ ← mat ← 3 4 ⍴⍳12
┌→─────────┐
↓1  2  3  4│
│5  6  7  8│
│9 10 11 12│
└~─────────┘
⌽ mat
┌→─────────┐
↓ 4  3  2 1│
│ 8  7  6 5│
│12 11 10 9│
└~─────────┘

dyadic (Rotate)

1 ⌽ 'HatStand'
┌→───────┐
│atStandH│
└────────┘
3 ⌽ 'HatStand'
┌→───────┐
│StandHat│
└────────┘
¯2 ⌽ 1 2 3 4 5 6
┌→──────────┐
│5 6 1 2 3 4│
└~──────────┘
⎕ ← mat ← 3 4 ⍴⍳12
┌→─────────┐
↓1  2  3  4│
│5  6  7  8│
│9 10 11 12│
└~─────────┘
¯1 ⌽ mat
┌→─────────┐
↓ 4 1  2  3│
│ 8 5  6  7│
│12 9 10 11│
└~─────────┘
1 ¯1 2 ⌽ mat
┌→─────────┐
↓ 2  3 4  1│
│ 8  5 6  7│
│11 12 9 10│
└~─────────┘

(Circle Bar)

monadic (Reverse First)

⊖ 'trams'
┌→────┐
│smart│
└─────┘
mat ← 3 4 ⍴⍳12
⊖ mat
┌→─────────┐
↓9 10 11 12│
│5  6  7  8│
│1  2  3  4│
└~─────────┘

dyadic (Rotate First)

3 ⊖ 'HatStand'
┌→───────┐
│StandHat│
└────────┘
mat ← 3 4 ⍴⍳12
¯1 ⊖ mat
┌→─────────┐
↓9 10 11 12│
│1  2  3  4│
│5  6  7  8│
└~─────────┘

(Circle Bar)

monadic (Transpose)

mat ← 3 4 ⍴⍳12
⍉ mat
┌→─────┐
↓1 5  9│
│2 6 10│
│3 7 11│
│4 8 12│
└~─────┘
⎕←cube ← 2 3 4 ⍴⍳24
┌┌→──────────┐
↓↓ 1  2  3  4│
││ 5  6  7  8│
││ 9 10 11 12│
││           │
││13 14 15 16│
││17 18 19 20│
││21 22 23 24│
└└~──────────┘
⍉ cube
┌┌→────┐
↓↓ 1 13│
││ 5 17│
││ 9 21│
││     │
││ 2 14│
││ 6 18│
││10 22│
││     │
││ 3 15│
││ 7 19│
││11 23│
││     │
││ 4 16│
││ 8 20│
││12 24│
└└~────┘
⍴⍉ cube
┌→────┐
│4 3 2│
└~────┘

dyadic (Rotate First)

mat ← 3 4 ⍴⍳12
2 1 ⍉ mat
┌→─────┐
↓1 5  9│
│2 6 10│
│3 7 11│
│4 8 12│
└~─────┘
1 1 ⍉ mat
┌→─────┐
│1 6 11│
└~─────┘
⎕ ← cube ← 2 3 4 ⍴⍳24
┌┌→──────────┐
↓↓ 1  2  3  4│
││ 5  6  7  8│
││ 9 10 11 12│
││           │
││13 14 15 16│
││17 18 19 20│
││21 22 23 24│
└└~──────────┘
⍴ 2 1 3 ⍉ cube
┌→────┐
│3 2 4│
└~────┘
1 1 1⍉ cube
┌→───┐
│1 18│
└~───┘
2 1 1⍉ cube
┌→────┐
↓ 1 13│
│ 6 18│
│11 23│
└~────┘

Other operators

(Quad Diamond)

Dyadic operator (Stencil)

{⊂⍺ ⍵}⌺3 3⊢3 3⍴⍳12
┌→──────────────────────────────────────────────────────────┐
↓ ┌→──────────────┐  ┌→──────────────┐  ┌→───────────────┐  │
│ │ ┌→──┐ ┌→────┐ │  │ ┌→──┐ ┌→────┐ │  │ ┌→───┐ ┌→────┐ │  │
│ │ │1 1│ ↓0 0 0│ │  │ │1 0│ ↓0 0 0│ │  │ │1 ¯1│ ↓0 0 0│ │  │
│ │ └~──┘ │0 1 2│ │  │ └~──┘ │1 2 3│ │  │ └~───┘ │2 3 0│ │  │
│ │       │0 4 5│ │  │       │4 5 6│ │  │        │5 6 0│ │  │
│ │       └~────┘ │  │       └~────┘ │  │        └~────┘ │  │
│ └∊──────────────┘  └∊──────────────┘  └∊───────────────┘  │
│ ┌→──────────────┐  ┌→──────────────┐  ┌→───────────────┐  │
│ │ ┌→──┐ ┌→────┐ │  │ ┌→──┐ ┌→────┐ │  │ ┌→───┐ ┌→────┐ │  │
│ │ │0 1│ ↓0 1 2│ │  │ │0 0│ ↓1 2 3│ │  │ │0 ¯1│ ↓2 3 0│ │  │
│ │ └~──┘ │0 4 5│ │  │ └~──┘ │4 5 6│ │  │ └~───┘ │5 6 0│ │  │
│ │       │0 7 8│ │  │       │7 8 9│ │  │        │8 9 0│ │  │
│ │       └~────┘ │  │       └~────┘ │  │        └~────┘ │  │
│ └∊──────────────┘  └∊──────────────┘  └∊───────────────┘  │
│ ┌→───────────────┐ ┌→───────────────┐ ┌→────────────────┐ │
│ │ ┌→───┐ ┌→────┐ │ │ ┌→───┐ ┌→────┐ │ │ ┌→────┐ ┌→────┐ │ │
│ │ │¯1 1│ ↓0 4 5│ │ │ │¯1 0│ ↓4 5 6│ │ │ │¯1 ¯1│ ↓5 6 0│ │ │
│ │ └~───┘ │0 7 8│ │ │ └~───┘ │7 8 9│ │ │ └~────┘ │8 9 0│ │ │
│ │        │0 0 0│ │ │        │0 0 0│ │ │         │0 0 0│ │ │
│ │        └~────┘ │ │        └~────┘ │ │         └~────┘ │ │
│ └∊───────────────┘ └∊───────────────┘ └∊────────────────┘ │
└∊──────────────────────────────────────────────────────────┘
s←2 2⍴3 3 2 2    ⍝ 2x2 stride with 3x3 kernel
({⊂⍵}⌺s)3 4⍴⍳12
┌→────────────────────┐
↓ ┌→────┐  ┌→────┐    │
│ ↓0 0 0│  ↓0 0 0│    │
│ │0 1 2│  │2 3 4│    │
│ │0 5 6│  │6 7 8│    │
│ └~────┘  └~────┘    │
│ ┌→─────┐ ┌→───────┐ │
│ ↓0 5  6│ ↓ 6  7  8│ │
│ │0 9 10│ │10 11 12│ │
│ │0 0  0│ │ 0  0  0│ │
│ └~─────┘ └~───────┘ │
└∊────────────────────┘

@ (At)

Dyadic @ (At)

(0@2 4) ⍳6
┌→──────────┐
│1 0 3 0 5 6│
└~──────────┘
(3 1@2 4) ⍳6
┌→──────────┐
│1 3 3 1 5 6│
└~──────────┘
÷@2 4 ⍳6
┌→───────────────┐
│1 0.5 3 0.25 5 6│
└~───────────────┘
10 (×@2 4) ⍳5
┌→──────────┐
│1 20 3 40 5│
└~──────────┘
0@(2∘|)⍳6
┌→──────────┐
│0 2 0 4 0 6│
└~──────────┘
⌽@(2∘|)⍳6
┌→──────────┐
│5 2 3 4 1 6│
└~──────────┘

Special non-math glyphs

& (Ampersand)

Monadic & (Spawn)

& spawns a new thread in which f is applied to its argument(s).

÷&4   ⍝ Reciprocal in background

(Branch)

Branching is superseded by the more modern control structures such as :If … :EndIf.

Variant

Used to pass options/variants to some system functions, such as JSON convert.

⎕←mat←(⎕JSON⍠('Format' 'M'))j
┌→────────────┐
↓   ┌⊖┐ ┌⊖┐   │
│ 0 │ │ │0│ 1 │
│   └─┘ └~┘   │
│   ┌→┐       │
│ 1 │a│ 1   3 │
│   └─┘       │
│   ┌→┐       │
│ 1 │b│ 42  3 │
│   └─┘       │
└∊────────────┘
1(⎕JSON⍠('Format' 'M')) mat
┌→─────────────┐
│{"a":1,"b":42}│
└──────────────┘

(I-Beam)

I-Beam is a monadic operator that provides a range of system related services. WARNING: Although documentation is provided for I-Beam functions, any service provided using I-Beam should be considered as “experimental” and subject to change. As at Aug-2022 services include SVD, probability distributions, and much more.

(Hydrant)

Monadic (Execute expression)

⍎ '1+1'
 
2
 
V ← 1 2 3
⍎ 'V'
┌→────┐
│1 2 3│
└~────┘
A← ⍎'1+1 ⋄ 2+2'
 
2
 
A
 
4
 

Dyadic (Execute expression in given namespace)

X must be a namespace reference or a simple character scalar or vector representing the name of a namespace in which the expression is to be executed.

(Thorn)

Monadic (Format)

4 5 6  ⍝ These are numbers (see the `~` in bottom left)
┌→────┐
│4 5 6│
└~────┘
⍕ 4 5 6  ⍝ These are characters (no `~` in bottom left)
┌→────┐
│4 5 6│
└─────┘

Dyadic (Format By Specification)

Field-width and number of decimal places:

6 2 ⍕ 3.125 0.002
┌→───────────┐
│  3.13  0.00│
└────────────┘