1 Total Array Ordering Ja y Foad & Ad á m Brudzews ky

大道至簡 ⍒⍋ 2 Gr ad i n g

⍋'APL' 1 3 2 3 Gr ad i n g

⍋'APL' 1 3 2 4 Gr ad i n g [1,2,3] ⍋'APL' 1 3 2 'A' 'L' 'P' 5 Major Cells: Vect or ┌→──┐ │APL│ └───┘ 6 Major Cells: Mat rix ┌→──┐ ↓AAA│ │PPP│ │LLL│ └───┘ 7 M a o r Ce l l s : Cu b e ┌→──┐ ↓AAA│ │AAA│──┐ │AAA│PP│ └───┘PP│──┐ │PPP│LL│ └───┘LL│ │LLL│ └───┘ 8 Major Cells: mat ┌→─────┐ ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘ 9 Major Cells: mat ⍋mat ┌→─────┐ 3 5 1 4 2 ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘ 10 Major Cells: mat ⍋mat ┌→─────┐ 3 5 1 4 2 ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘ 11 Major Cells: mat mat[⍋mat;] ┌→─────┐ ┌→─────┐ ↓John │ ↓Adam │ │Roger │ │Jay │ │Adam │ │John │ │Morten│ │Morten│ │Jay │ │Roger │ └──────┘ └──────┘ 12 Sor t i ng mat[⍋mat;] {(⊂⍋⍵)⌷⍵} mat 13 Sor t i ng mat[⍋mat;] {(⊂⍋⍵)⌷⍵} mat 14 Sor t i ng mat[⍋mat;] {(⊂⍒⍵)⌷⍵} mat 15 Sor t i ng mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} 16 Sor t i ng mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} Sort mat 17 Sor t i ng mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} Sort mat Adam Jay John Morten Roger 18 Sor t i ng n ← 'Roger' 'Adam' 'Jay' 19 Sor t i ng n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 20 Sor t i ng n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAI N ERROR 21 Sor t i ng n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAI N ERROR Sort n ⍝ 17.0 22 Sor t i ng n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAI N ERROR Sort n ⍝ 17.0 ┌────┬───┬─────┐ │Adam│Jay│Roger│ └────┴───┴─────┘ 23

⍝ That's all, folks! 24

Total Array Ordering 25 Hist ory 'Morten' 'Roger ' 26 Hist ory 'Morten' 'Roger▉' 27 Hist ory A ← 'Morten' B ← 'Roger▉' 28 Hist ory A ← 'Morten' B ← 'Roger▉'

⍋ A ,[0.5] B 1 2 29 Hist ory A ← 'Morten' B ← 'Roger▉'

⍋ A ,[0.5] B 1 2

'Morten ≺ 'Roger▉' 30 Total Array Ordering

some other array array ? 31 Total Array Ordering How would you order: ⎕ ← 0 'Jay' (2 3⍴'DYALOG') (⍳9) ┌→──────────────────────────────────┐ │ ┌→──┐ ┌→──┐ ┌→────────────────┐ │ │ 0 │Jay│ ↓DYA│ │1 2 3 4 5 6 7 8 9│ │ │ └───┘ │LOG│ └~────────────────┘ │ │ └───┘ │ └∊──────────────────────────────────┘ 32 Total Array Ordering How would you order: ⎕ ← 0 'Jay' (2 3⍴'DYALOG') (⍳9) ┌→──────────────────────────────────┐ │ ┌→──┐ ┌→──┐ ┌→────────────────┐ │ │ 0 │Jay│ ↓DYA│ │1 2 3 4 5 6 7 8 9│ │ │ └───┘ │LOG│ └~────────────────┘ │ │ └───┘ │ └∊──────────────────────────────────┘ 33 TAO 34 TAO Rul es 35 TAO

some other array array ? 36 TAO

some other array array ? 37 TAO

some other array array ? no refs no refs 38 TAO Rul es 39 TAO Rul es Compatibility: simple arrays 40 TAO Rul es Compatibility: simple arrays Consistency: (⍺ ⍵)∧(⍵ ⍺) ⍺ ⍵ 41 TAO Rul es Compatibility: simple arrays Consistency: (⍺ ⍵)∧(⍵ ⍺) ⍺ ⍵ ⍺≡⍵ 42 TAO Rul es Compatibility: simple arrays Consistency: (⍺ ⍵)∧(⍵ ⍺) ⍺ ⍵ ⍺≡⍵ ⍬≢'' 43 TAO Rules: simple scalars 44 TAO Rules: simple scalars character vs character: ✓ 45 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ 46 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ complex: 1 1J1 2J¯1 2 47 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ complex: 1 1J1 2J¯1 2 number vs character: 100 ' A' 48 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ complex: 1 1J1 2J¯1 2 number vs character: 100 ' A' null: ⎕NULL ¯100 49 TAO Rules: simple scalars

⎕NULL ¯1 0J¯2 0 0J2 1 ' A' 50 TAO Rules: same shape 51 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ 52 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ 53 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘ 54 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘ 55 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT 56 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT 57 TAO Rules: different shape

CAR CARPENTER 58 TAO Rules: different shape

CAR CARPENTER 59 TAO Rules: different shape

CAR CARPENTER 60 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT 61 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT 62 TAO Rules: different shape

↑'CAR' 'CARPENTER' 63 TAO Rules: different shape

↑'CAR' 'CARPENTER' CAR▉▉▉▉▉▉ CARPENTER 64 TAO Rules: different shape

↑'CAR' 'CAR␀␀␀␀␀␀' CAR▉▉▉▉▉▉ CAR␀␀␀␀␀␀ 65 TAO Rules: different shape

⍋↑'CAR' 'CAR␀␀␀␀␀␀' 2 1 66 TAO Rules: different shape

⍋↑'CAR' 'CAR␀␀␀␀␀␀' 2 1 67 TAO Rules: different shape

1 2 3 1 2 3 4 68 TAO Rules: different shape

¯1 ¯2 ¯3 ¯1 ¯2 ¯3 ¯4 69 TAO Rules: different shape

¯1 ¯2 ¯3 ¯1 ¯2 ¯3 ¯4 70 TAO Rules: different shape

↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 71 TAO Rules: different shape

↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) ¯1 ¯2 ¯3 0 ¯1 ¯2 ¯3 ¯4 72 TAO Rules: different shape

⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 73 TAO Rules: different shape

⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 2 1 74 TAO Rules: different shape

⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 2 1 75 TAO Rules: different shape ¯∞ 76 TAO Rules: different shape

¯∞ ⎕NULL ¯1 0J¯2 0 0J2 1 ' A' 77 TAO Rules: different shape

CAR¯∞¯∞¯∞¯∞¯∞¯∞ CARPENTER 78 TAO Rules: different shape

CAR¯∞¯∞¯∞¯∞¯∞¯∞ CARPENTER 79 TAO Rules: different shape

1 2 1 2 3 1 2 1 2 3 1 2 80 TAO Rules: different shape

1 2 ¯∞ 1 2 3 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ 81 TAO Rules: different shape

1 2 ¯∞ 1 2 3 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ 82 TAO Rules: different shape

1 2 ¯∞ 1 2 3 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ 83 TAO Rules: different rank ┌→──┐ ┌→────┐ │APL│ ↓Adam │ └───┘ │Jay │ │Roger│ └─────┘ 84 TAO Rules: different rank ┌→──┐ ┌→────┐ ↓APL│ ↓Adam │ └───┘ │Jay │ │Roger│ └─────┘ 85 TAO Rules: different rank ┌→────┐ ┌→────┐ ↓APL¯∞¯∞│ ↓Adam │ │¯∞¯∞¯∞¯∞¯∞│ │Jay │ │¯∞¯∞¯∞¯∞¯∞│ │Roger│ └─────┘ └─────┘ 86 TAO Rules: different rank ┌→────┐ ┌→────┐ ↓APL¯∞¯∞│ ↓Adam │ │¯∞¯∞¯∞¯∞¯∞│ │Jay │ │¯∞¯∞¯∞¯∞¯∞│ │Roger│ └─────┘ └─────┘ 87 TAO Rules: different rank ┌→──┐ ┌→──┐ │APL│ ↓APL│ └───┘ └───┘ 88 TAO Rules: different rank ┌→──┐ ┌→──┐ ↓APL│ ↓APL│ └───┘ └───┘ 89 TAO Rules: different rank ┌→──┐ ┌→──┐ │APL│ ↓APL│ └───┘ └───┘ 1 2 90 TAO Rules: different rank

scalar vector 'A' 'APL' A APL

vector 1-row matrix 3⍴'APL' 1 3⍴'APL' APL APL 91 TAO Rules: recap simple scalars ⎕NULL nums chars same shape item-by-item in ravel order unequal shape pad with ¯∞ unequal rank prefix shape with 1s 92 TAO Rules: empt y arrays 2 0 0⍴⍬ 0 0 3⍴'' 93 TAO Rules: empt y arrays 2 0 0⍴⍬ 0 0 3⍴'' 94 TAO Rules: empt y arrays 2 0 0⍴⍬ 0 0 3⍴'' 2 0 3⍴⍬ 2 0 3⍴'' 95 TAO Rules: empt y arrays 2 0 0⍴⍬ 0 0 3⍴'' ⍬ prototypical items '' or 2 0 0 original shapes 0 0 3 ? 96 TAO Rules: empt y arrays 2 0 0⍴⍬ 0 0 3⍴'' ⍬ prototypical items '' 2 0 0 original shapes 0 0 3 97 TAO Rules: empt y arrays 2 0 0⍴⍬ 0 0 3⍴⍬ ⍬ prototypical items ⍬ 2 0 0 original shapes 0 0 3 98 TAO Rul es simple scalars ⎕NULL nums chars same shape item-by-item in ravel order unequal shape pad with ¯∞ unequal rank prefix shape with 1s both empty type then shape 99 TAO Scope ⍋⍵

⍒⍵

⍺⍸⍵ 100 TAO: a t rue t eam effort Arthur Whitney initial suggestion Roger Hui TAO o f J John Scholes model: dfns.dyalog.com/ n_ le.htm Roger Hui Dya log implementation

Adám Brudzewsky, Roger Hui, Jay Foad, John Scholes, Morten Kromberg 101 TAO: a t rue t eam effort Arthur Whitney initial suggestion Roger Hui TAO o f J John Scholes model: dfns.dyalog.com/ n_ le.htm Roger Hui Dya log implementation

Adám Brudzewsky, Roger Hui, Jay Foad, John Scholes, Morten Kromberg 102 TAO: a t rue t eam effort Arthur Whitney initial suggestion Roger Hui TAO o f J John Scholes model: dfns.dyalog.com/ n_ le.htm Roger Hui Dya log implementation

Adám Brudzewsky, Roger Hui, Jay Foad, John Scholes, Morten Kromberg 103 TAO: a t rue t eam effort Arthur Whitney initial suggestion Roger Hui TAO o f J John Scholes model: dfns.dyalog.com/ n_ le.htm Roger Hui Dya log implementation

Adám Brudzewsky, Roger Hui, Jay Foad, John Scholes, Morten Kromberg 104 TAO: a t rue t eam effort Arthur Whitney initial suggestion Roger Hui TAO o f J John Scholes model: dfns.dyalog.com/ n_ le.htm Roger Hui Dya log implementation

Adám Brudzewsky, Roger Hui, Jay Foad, John Scholes, Morten Kromberg 105

Features coming in version 17.0… 106 Demo Phonebook Record Insertion Natural Sorting ]load /tao/pb )clear Sort ← {(⊂⍋⍵)⌷⍵} ]load /tao/names Sort pb Digits ← {⍵∊⎕D} pb ← Sort pb Digits 'my10b' new ← 'Kromberg' 'Morten' 584 CutOffs ← {1,2≠/Digits ⍵} pb ⍸ new CutOffs 'my10b' (2↑pb)⍪new⍪(2↓pb) Parts ← {(CutOffs ⍵)⊂⍵} 2(↑⍪new⍪↓)pb Parts 'my10b' Into ← {(⍵⍸⍺)(↑⍪⍺⍪↓)⍵} ExecNums ← {∧/Digits ⍵:⍎⍵ ⋄ ⍵} new Into pb ExecNums¨Parts 'my10b' Order ← {⍋ExecNums¨∘Parts¨⍵} Spreadsheet Dat a Types Order names ss ← (⎕NEW⊂'Clipboard').Array NatSort ← {(⊂Order ⍵)⌷⍵} Sort ss NatSort names ss[⍋ss[;1 3];] ]defs -topdown 107 Feat ures coming in version 17.0 Grade and Sort anyno refs Array

{(⊂⍋⍵}⌷⍵} for all ranks – fast!

⍋⍵ ⍒⍵ ⍺⍸⍵ 108 Webinars on Thursdays at 15:00 UTC Comment and suggest to [email protected] or @ Ad á m in chat.stackexchange.com/rooms/52405 April 19 APL Processes and Isolates in the Clouds May 17 to be announced June 21 to be announced General APL Quest ions stackoverflow.com