Fun with Total Array Ordering (TAO) ⍒⍋

Fun with Total Array Ordering (TAO) ⍒⍋

1 Adám Brudzewsky (material by Jay Foad) 大道至簡 Fun with Total Array Ordering (TAO) ⍒⍋ Fun with Total Array Ordering (TAO) 2 Grading ⍋'APL' 1 3 2 Fun with Total Array Ordering (TAO) 3 Grading ⍋'APL' 1 3 2 Fun with Total Array Ordering (TAO) 4 Grading [1,2,3] ⍋'APL' 1 3 2 'A' 'L' 'P' ⍨ Fun with Total Array Ordering (TAO) 5 Major Cells: Vector ┌→──┐ │APL│ └───┘ Fun with Total Array Ordering (TAO) 6 Major Cells: Matrix ┌→──┐ ↓AAA│ │PPP│ │LLL│ └───┘ Fun with Total Array Ordering (TAO) 7 Major Cells: Cube ┌→──┐ ↓AAA│ │AAA│──┐ │AAA│PP│ └───┘PP│──┐ │PPP│LL│ └───┘LL│ │LLL│ └───┘ Fun with Total Array Ordering (TAO) 8 Major Cells: mat ┌→─────┐ ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘ Fun with Total Array Ordering (TAO) 9 Major Cells: mat ⍋mat ┌→─────┐ 3 5 1 4 2 ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘ Fun with Total Array Ordering (TAO) 10 Major Cells: mat ⍋mat ┌→─────┐ 3 5 1 4 2 ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘ Fun with Total Array Ordering (TAO) 11 Major Cells: mat mat[⍋mat;] ┌→─────┐ ┌→─────┐ ↓John │ ↓Adam │ │Roger │ │Jay │ │Adam │ │John │ │Morten│ │Morten│ │Jay │ │Roger │ └──────┘ └──────┘ Fun with Total Array Ordering (TAO) 12 Sorting mat[⍋mat;] {(⊂⍋⍵)⌷⍵} mat Fun with Total Array Ordering (TAO) 13 Sorting mat[⍋mat;] {(⊂⍋⍵)⌷⍵} mat Fun with Total Array Ordering (TAO) 14 Sorting mat[⍋mat;] {(⊂⍒⍵)⌷⍵} mat Fun with Total Array Ordering (TAO) 15 Sorting mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} Fun with Total Array Ordering (TAO) 16 Sorting mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} Sort mat Fun with Total Array Ordering (TAO) 17 Sorting mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} Sort mat Adam Jay John Morten Roger Fun with Total Array Ordering (TAO) 18 Sorting n ← 'Roger' 'Adam' 'Jay' Fun with Total Array Ordering (TAO) 19 Sorting n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 Fun with Total Array Ordering (TAO) 20 Sorting n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAIN ERROR Fun with Total Array Ordering (TAO) 21 Sorting n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAIN ERROR Sort n ⍝ 17.0 Fun with Total Array Ordering (TAO) 22 Sorting n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAIN ERROR Sort n ⍝ 17.0 ┌────┬───┬─────┐ │Adam│Jay│Roger│ └────┴───┴─────┘ Fun with Total Array Ordering (TAO) 23 A bit of history 'Morten' 'Roger ' Fun with Total Array Ordering (TAO) 24 A bit of history 'Morten' 'Roger▉' Fun with Total Array Ordering (TAO) 25 A bit of history A ← 'Morten' B ← 'Roger▉' Fun with Total Array Ordering (TAO) 26 A bit of history A ← 'Morten' B ← 'Roger▉' ⍋ A ,[0.5] B 1 2 Fun with Total Array Ordering (TAO) 27 A bit of history A ← 'Morten' B ← 'Roger▉' ⍋ A ,[0.5] B 1 2 'Morten' 'Roger▉' Fun with Total Array Ordering (TAO) 28 Total Array Ordering some other array array ? Fun with Total Array Ordering (TAO) 29 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│ └~────────────────┘ │ │ └───┘ │ └∊──────────────────────────────────┘ Fun with Total Array Ordering (TAO) 30 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│ └~────────────────┘ │ │ └───┘ │ └∊──────────────────────────────────┘ Fun with Total Array Ordering (TAO) 31 Total Array Ordering Fun with Total Array Ordering (TAO) 32 TAO Fun with Total Array Ordering (TAO) 33 TAO Rules Fun with Total Array Ordering (TAO) 34 TAO some other array array ? Fun with Total Array Ordering (TAO) 35 TAO some other array array ? Fun with Total Array Ordering (TAO) 36 TAO some other array array ? no refs no refs Fun with Total Array Ordering (TAO) 37 TAO Rules Fun with Total Array Ordering (TAO) 38 TAO Rules Compatibility: simple arrays Fun with Total Array Ordering (TAO) 39 TAO Rules Compatibility: simple arrays Consistency: (⍺ ⍵)∧(⍵ ⍺) ⍺ ⍵ Fun with Total Array Ordering (TAO) 40 TAO Rules Compatibility: simple arrays Consistency: (⍺ ⍵)∧(⍵ ⍺) ⍺ ⍵ ⍺≡⍵ Fun with Total Array Ordering (TAO) 41 TAO Rules Compatibility: simple arrays Consistency: (⍺ ⍵)∧(⍵ ⍺) ⍺ ⍵ ⍺≡⍵ ⍬≢'' Fun with Total Array Ordering (TAO) 42 TAO Rules: simple scalars Fun with Total Array Ordering (TAO) 43 TAO Rules: simple scalars character vs character: ✓ Fun with Total Array Ordering (TAO) 44 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ Fun with Total Array Ordering (TAO) 45 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ complex: 1 1J1 2J¯1 2 Fun with Total Array Ordering (TAO) 46 TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ complex: 1 1J1 2J¯1 2 number vs character: 100 'A' Fun with Total Array Ordering (TAO) 47 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 Fun with Total Array Ordering (TAO) 48 TAO Rules: simple scalars ⎕NULL ¯1 0J¯2 0 0J2 1 'A' Fun with Total Array Ordering (TAO) 49 TAO Rules: same shape Fun with Total Array Ordering (TAO) 50 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ Fun with Total Array Ordering (TAO) 51 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ Fun with Total Array Ordering (TAO) 52 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘ Fun with Total Array Ordering (TAO) 53 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘ Fun with Total Array Ordering (TAO) 54 TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘ Fun with Total Array Ordering (TAO) 55 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT Fun with Total Array Ordering (TAO) 56 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT Fun with Total Array Ordering (TAO) 57 TAO Rules: different shape CAR CARPENTER Fun with Total Array Ordering (TAO) 58 TAO Rules: different shape CAR CARPENTER Fun with Total Array Ordering (TAO) 59 TAO Rules: different shape CAR CARPENTER Fun with Total Array Ordering (TAO) 60 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT Fun with Total Array Ordering (TAO) 61 TAO Rules: different shape CAN CAR CARPENTER CARPET CAT Fun with Total Array Ordering (TAO) 62 TAO Rules: different shape ↑'CAR' 'CARPENTER' Fun with Total Array Ordering (TAO) 63 TAO Rules: different shape ↑'CAR' 'CARPENTER' CAR▉▉▉▉▉▉ CARPENTER Fun with Total Array Ordering (TAO) 64 TAO Rules: different shape ↑'CAR' 'CAR␀␀␀␀␀␀' CAR▉▉▉▉▉▉ CAR␀␀␀␀␀␀ Fun with Total Array Ordering (TAO) 65 TAO Rules: different shape ⍋↑'CAR' 'CAR␀␀␀␀␀␀' 2 1 Fun with Total Array Ordering (TAO) 66 TAO Rules: different shape ⍋↑'CAR' 'CAR␀␀␀␀␀␀' 2 1 Fun with Total Array Ordering (TAO) 67 TAO Rules: different shape 1 2 3 1 2 3 4 Fun with Total Array Ordering (TAO) 68 TAO Rules: different shape ¯1 ¯2 ¯3 ¯1 ¯2 ¯3 ¯4 Fun with Total Array Ordering (TAO) 69 TAO Rules: different shape ¯1 ¯2 ¯3 ¯1 ¯2 ¯3 ¯4 Fun with Total Array Ordering (TAO) 70 TAO Rules: different shape ↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) Fun with Total Array Ordering (TAO) 71 TAO Rules: different shape ↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) ¯1 ¯2 ¯3 0 ¯1 ¯2 ¯3 ¯4 Fun with Total Array Ordering (TAO) 72 TAO Rules: different shape ⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) Fun with Total Array Ordering (TAO) 73 TAO Rules: different shape ⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 2 1 Fun with Total Array Ordering (TAO) 74 TAO Rules: different shape ⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 2 1 Fun with Total Array Ordering (TAO) 75 TAO Rules: different shape ¯∞ Fun with Total Array Ordering (TAO) 76 TAO Rules: different shape ¯∞ ⎕NULL ¯1 0J¯2 0 0J2 1 'A' Fun with Total Array Ordering (TAO) 77 TAO Rules: different shape CAR¯∞¯∞¯∞¯∞¯∞¯∞ CARPENTER Fun with Total Array Ordering (TAO) 78 TAO Rules: different shape CAR¯∞¯∞¯∞¯∞¯∞¯∞ CARPENTER Fun with Total Array Ordering (TAO) 79 TAO Rules: different shape 1 2 1 2 3 1 2 1 2 3 1 2 Fun with Total Array Ordering (TAO) 80 TAO Rules: different shape 1 2 ¯∞ 1 2 3 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ Fun with Total Array Ordering (TAO) 81 TAO Rules: different shape 1 2 ¯∞ 1 2 3 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ Fun with Total Array Ordering (TAO) 82 TAO Rules: different shape 1 2 ¯∞ 1 2 3 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ Fun with Total Array Ordering (TAO) 83 TAO Rules: different rank ┌→──┐ ┌→────┐ │APL│ ↓Adam │ └───┘ │Jay │ │Roger│ └─────┘ Fun with Total Array Ordering (TAO) 84 TAO Rules: different rank ┌→──┐ ┌→────┐ ↓APL│ ↓Adam │ └───┘ │Jay │ │Roger│ └─────┘ Fun with Total Array Ordering (TAO) 85 TAO Rules: different rank ┌→────┐ ┌→────┐ ↓APL¯∞¯∞│ ↓Adam │ │¯∞¯∞¯∞¯∞¯∞│ │Jay │ │¯∞¯∞¯∞¯∞¯∞│ │Roger│ └─────┘ └─────┘ Fun with Total Array Ordering (TAO) 86 TAO Rules: different rank ┌→────┐ ┌→────┐ ↓APL¯∞¯∞│ ↓Adam │ │¯∞¯∞¯∞¯∞¯∞│ │Jay │ │¯∞¯∞¯∞¯∞¯∞│ │Roger│ └─────┘ └─────┘ Fun with Total Array Ordering (TAO) 87 TAO Rules: different rank ┌→──┐ ┌→──┐ │APL│ ↓APL│ └───┘ └───┘ Fun with Total Array Ordering (TAO) 88 TAO Rules: different rank ┌→──┐ ┌→──┐ ↓APL│ ↓APL│ └───┘ └───┘ Fun with Total Array Ordering (TAO) 89 TAO Rules: different rank ┌→──┐ ┌→──┐ │APL│ ↓APL│ └───┘ └───┘ 1 2 Fun with Total Array Ordering (TAO) 90 TAO Rules: different rank scalar vector 'A' ,'A' A A vector 1-row matrix 3⍴'APL' 1 3⍴'APL' APL APL Fun with Total Array Ordering (TAO) 91 TAO Rules: recap simple scalars

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    108 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us