⍝ Reduced version of disp:
dsp'hello' 'world' ⍝ nested vector as tree
───────────
hello│world
cmp ← ⍕(display eis disp eis dsp eis 0∘dsp) ⍝ display v disp v dsp v 0∘dsp
cmp'hello' 'world'
┌→────────────────┐ ┌─────┬─────┐ ─────────── hello│world
│ ┌→────┐ ┌→────┐ │ │hello│world│ hello│world
│ │hello│ │world│ │ └─────┴─────┘
│ └─────┘ └─────┘ │
└∊────────────────┘
cmp ⊃,∘⊂/⍳5
┌→────────────────────┐ ┌─┬───────────┐ ───────── 1│───────
│ ┌→──────────────┐ │ │1│┌─┬───────┐│ 1│─────── 2│─────
│ 1 │ ┌→────────┐ │ │ │ ││2│┌─┬───┐││ 2│───── 3│4 5
│ │ 2 │ ┌→──┐ │ │ │ │ ││ ││3│4 5│││ 3│4 5
│ │ │ 3 │4 5│ │ │ │ │ ││ │└─┴───┘││
│ │ │ └~──┘ │ │ │ │ │└─┴───────┘│
│ │ └∊────────┘ │ │ └─┴───────────┘
│ └∊──────────────┘ │
└∊────────────────────┘
cmp ↓↓2 2 2⍴⎕a
┌→────────────────────────────┐ ┌───────┬───────┐ ─────────── ─────│─────
│ ┌→──────────┐ ┌→──────────┐ │ │┌──┬──┐│┌──┬──┐│ ─────│───── AB│CD│EF│GH
│ │ ┌→─┐ ┌→─┐ │ │ ┌→─┐ ┌→─┐ │ │ ││AB│CD│││EF│GH││ AB│CD│EF│GH
│ │ │AB│ │CD│ │ │ │EF│ │GH│ │ │ │└──┴──┘│└──┴──┘│
│ │ └──┘ └──┘ │ │ └──┘ └──┘ │ │ └───────┴───────┘
│ └∊──────────┘ └∊──────────┘ │
└∊────────────────────────────┘
tape←{'∘',(⍺↑⍵),{⍺ ⍵}/⍺↓⍵,'∘'} ⍝ ⍺-window tape: see →bf←
rgt←{(⊂2↑⍵),(2↓¯1↓⍵),⊃⌽⍵} ⍝ tape-head moves right 1 item
0 dsp rgt⍣5 ⊢2 tape 2/¨12↑⎕A ⍝ skipping right along 2-tape
────────────────│FF│GG│────────────────
─────────────│EE HH│─────────────
──────────│DD II│──────────
───────│CC JJ│───────
────│BB KK│────
∘│AA LL│∘
cmp ⍳2 2 ⍝ rank-2 nested array
┌→────────────┐ ┌───┬───┐ ─────── 1 1│1 2
↓ ┌→──┐ ┌→──┐ │ │1 1│1 2│ 1 1│1 2 ───┼───
│ │1 1│ │1 2│ │ ├───┼───┤ ───┼─── 2 1│2 2
│ └~──┘ └~──┘ │ │2 1│2 2│ 2 1│2 2
│ ┌→──┐ ┌→──┐ │ └───┴───┘
│ │2 1│ │2 2│ │
│ └~──┘ └~──┘ │
└∊────────────┘
cmp ↑¨¨↑¨↓↓↓↓(6/2)⍴⎕a ⍝ nested matrices
┌→────────────────────────────┐ ┌───────┬───────┐ ─────────── AB│EF│QR│UV
↓ ┌→──────────┐ ┌→──────────┐ │ │┌──┬──┐│┌──┬──┐│ ─────│───── CD│GH│ST│WX
│ ↓ ┌→─┐ ┌→─┐ │ ↓ ┌→─┐ ┌→─┐ │ │ ││AB│EF│││QR│UV││ AB│EF│QR│UV ──┼──│──┼──
│ │ ↓AB│ ↓EF│ │ │ ↓QR│ ↓UV│ │ │ ││CD│GH│││ST│WX││ CD│GH│ST│WX IJ│MN│YZ│CD
│ │ │CD│ │GH│ │ │ │ST│ │WX│ │ │ │├──┼──┤│├──┼──┤│ ──┼──│──┼── KL│OP│AB│EF
│ │ └──┘ └──┘ │ │ └──┘ └──┘ │ │ ││IJ│MN│││YZ│CD││ IJ│MN│YZ│CD ─────┼─────
│ │ ┌→─┐ ┌→─┐ │ │ ┌→─┐ ┌→─┐ │ │ ││KL│OP│││AB│EF││ KL│OP│AB│EF GH│KL│WX│AB
│ │ ↓IJ│ ↓MN│ │ │ ↓YZ│ ↓CD│ │ │ │└──┴──┘│└──┴──┘│ ─────┼───── IJ│MN│YZ│CD
│ │ │KL│ │OP│ │ │ │AB│ │EF│ │ │ ├───────┼───────┤ ─────│───── ──┼──│──┼──
│ │ └──┘ └──┘ │ │ └──┘ └──┘ │ │ │┌──┬──┐│┌──┬──┐│ GH│KL│WX│AB OP│ST│EF│IJ
│ └∊──────────┘ └∊──────────┘ │ ││GH│KL│││WX│AB││ IJ│MN│YZ│CD QR│UV│GH│KL
│ ┌→──────────┐ ┌→──────────┐ │ ││IJ│MN│││YZ│CD││ ──┼──│──┼──
│ ↓ ┌→─┐ ┌→─┐ │ ↓ ┌→─┐ ┌→─┐ │ │ │├──┼──┤│├──┼──┤│ OP│ST│EF│IJ
│ │ ↓GH│ ↓KL│ │ │ ↓WX│ ↓AB│ │ │ ││OP│ST│││EF│IJ││ QR│UV│GH│KL
│ │ │IJ│ │MN│ │ │ │YZ│ │CD│ │ │ ││QR│UV│││GH│KL││
│ │ └──┘ └──┘ │ │ └──┘ └──┘ │ │ │└──┴──┘│└──┴──┘│
│ │ ┌→─┐ ┌→─┐ │ │ ┌→─┐ ┌→─┐ │ │ └───────┴───────┘
│ │ ↓OP│ ↓ST│ │ │ ↓EF│ ↓IJ│ │ │
│ │ │QR│ │UV│ │ │ │GH│ │KL│ │ │
│ │ └──┘ └──┘ │ │ └──┘ └──┘ │ │
│ └∊──────────┘ └∊──────────┘ │
└∊────────────────────────────┘
cmp ⍳4/2 ⍝ rank-4 array
┌┌┌→────────────────────┐ ┌───────┬───────┐ ─────────────── 1 1 1 1│1 1 1 2
↓↓↓ ┌→──────┐ ┌→──────┐ │ │1 1 1 1│1 1 1 2│ 1 1 1 1│1 1 1 2 ───────┼───────
│││ │1 1 1 1│ │1 1 1 2│ │ ├───────┼───────┤ ───────┼─────── 1 1 2 1│1 1 2 2
│││ └~──────┘ └~──────┘ │ │1 1 2 1│1 1 2 2│ 1 1 2 1│1 1 2 2
│││ ┌→──────┐ ┌→──────┐ │ └───────┴───────┘ 2 1 1 1│2 1 1 2
│││ │1 1 2 1│ │1 1 2 2│ │ ┌───────┬───────┐ 2 1 1 1│2 1 1 2 ───────┼───────
│││ └~──────┘ └~──────┘ │ │1 2 1 1│1 2 1 2│ ───────┼─────── 2 1 2 1│2 1 2 2
│││ │ ├───────┼───────┤ 2 1 2 1│2 1 2 2
│││ ┌→──────┐ ┌→──────┐ │ │1 2 2 1│1 2 2 2│
│││ │1 2 1 1│ │1 2 1 2│ │ └───────┴───────┘ 1 2 1 1│1 2 1 2
│││ └~──────┘ └~──────┘ │ 1 2 1 1│1 2 1 2 ───────┼───────
│││ ┌→──────┐ ┌→──────┐ │ ┌───────┬───────┐ ───────┼─────── 1 2 2 1│1 2 2 2
│││ │1 2 2 1│ │1 2 2 2│ │ │2 1 1 1│2 1 1 2│ 1 2 2 1│1 2 2 2
│││ └~──────┘ └~──────┘ │ ├───────┼───────┤ 2 2 1 1│2 2 1 2
│││ │ │2 1 2 1│2 1 2 2│ 2 2 1 1│2 2 1 2 ───────┼───────
│││ │ └───────┴───────┘ ───────┼─────── 2 2 2 1│2 2 2 2
│││ ┌→──────┐ ┌→──────┐ │ ┌───────┬───────┐ 2 2 2 1│2 2 2 2
│││ │2 1 1 1│ │2 1 1 2│ │ │2 2 1 1│2 2 1 2│
│││ └~──────┘ └~──────┘ │ ├───────┼───────┤
│││ ┌→──────┐ ┌→──────┐ │ │2 2 2 1│2 2 2 2│
│││ │2 1 2 1│ │2 1 2 2│ │ └───────┴───────┘
│││ └~──────┘ └~──────┘ │
│││ │
│││ ┌→──────┐ ┌→──────┐ │
│││ │2 2 1 1│ │2 2 1 2│ │
│││ └~──────┘ └~──────┘ │
│││ ┌→──────┐ ┌→──────┐ │
│││ │2 2 2 1│ │2 2 2 2│ │
│││ └~──────┘ └~──────┘ │
└└└∊────────────────────┘
⍕↑{cmp 0,⊂⊂⊂⍳⍵}¨2 1 0 ⍝ enclosed empty disappears
┌→────────────────┐ ┌─┬───────┐ ───── 0│───
│ ┌───────────┐ │ │0│┌─────┐│ 0│─── ───
│ 0 │ ┌───────┐ │ │ │ ││┌───┐││ ─── 1 2
│ │ │ ┌→──┐ │ │ │ │ │││1 2│││ 1 2
│ │ │ │1 2│ │ │ │ │ ││└───┘││
│ │ │ └~──┘ │ │ │ │ │└─────┘│
│ │ └∊──────┘ │ │ └─┴───────┘
│ └∊──────────┘ │
└∊────────────────┘
┌→──────────────┐ ┌─┬─────┐ ─── 0│─
│ ┌─────────┐ │ │0│┌───┐│ 0│─ ─
│ 0 │ ┌─────┐ │ │ │ ││┌─┐││ ─ 1
│ │ │ ┌→┐ │ │ │ │ │││1│││ 1
│ │ │ │1│ │ │ │ │ ││└─┘││
│ │ │ └~┘ │ │ │ │ │└───┘│
│ │ └∊────┘ │ │ └─┴─────┘
│ └∊────────┘ │
└∊──────────────┘
┌→──────────────┐ ┌─┬────┐ ── 0│
│ ┌─────────┐ │ │0│┌──┐│ 0│
│ 0 │ ┌─────┐ │ │ │ ││┌┐││
│ │ │ ┌⊖┐ │ │ │ │ ││││││
│ │ │ │0│ │ │ │ │ ││└┘││
│ │ │ └~┘ │ │ │ │ │└──┘│
│ │ └∊────┘ │ │ └─┴────┘
│ └∊────────┘ │
└∊──────────────┘
⍕dsp¨(⊂∘⊃,⊂∘⊢,⊂∘⊂,⊂∘⊂∘⊂)'hello' 'world' ⍝ top-bar indicates depth
hello ─────────── ─────────── ───────────
hello│world ─────────── ───────────
hello│world ───────────
hello│world
⍕0 dsp¨(⊂∘⊃,⊂∘⊢,⊂∘⊂,⊂∘⊂∘⊂)'hello' 'world' ⍝ ditto with top-bar supressed
hello hello│world ─────────── ───────────
hello│world ───────────
hello│world
⍝∇ dsp disp display eis
Back to: code
Back to: Workspaces