⍝ Boxed sketch of nested array:
disp 2 2⍴'Tea'(2 1⍴4 2)'&'(2 40) ⍝ <disp> form of nested array.
┌───┬────┐
│Tea│4 │
│ │2 │
├───┼────┤
│& │2 40│
└───┴────┘
1 disp 'ABC'(1 4⍴1 2 3 4)(0 1 0⍴0)(⎕SE #)('88',99)
┌→──┬───────┬─┬────────┬─────┐
│ABC│1 2 3 4↓0⍒ ⎕SE # │88 99│
└──→┴~─────→┴⊖┴#──────→┴+───→┘
disp'%' 'Eye Poke' 'Kumquat'⍪↑('Guys' 60 40)('Dolls' 20 80)
┌─────┬────────┬───────┐
│% │Eye Poke│Kumquat│
├─────┼────────┼───────┤
│Guys │60 │40 │
├─────┼────────┼───────┤
│Dolls│20 │80 │
└─────┴────────┴───────┘
1 disp ('88',99)(88,'99') ⍝ ambiguous cases.
┌→────┬─────┐
│88 99│88 99│
└+───→┴+───→┘
1 disp ⎕tc,⊂'' ⍝ terminal control characters.
┌→┬─┬─┬─┐
│ │ │ │ │
│ │ │ │ │
└─┴─┴─┴⊖┘
1 disp,¨⎕tc
┌→┬─┬─┐
│ │ │ │
│ │ │ │
└→┴→┴→┘
1 disp⊂⎕tc
┌─┐
│ │
│ │
│ │
└→┘
1 disp ⎕tc,⊂⎕tc
┌→┬─┬─┬─┐
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
└─┴─┴─┴→┘
disp ⎕or'disp' ⍝ ⎕OR-s.
∇disp
1 disp {⍵ ⍵}⎕or'disp'
┌→──────┬───────┐
│ ∇disp │ ∇disp │
└∇──────┴∇──────┘
1 disp # ⍝ namespaces
#
1 disp # #
# #
1 disp ⊂# #
┌──────┐
│ # # │
└#────→┘
'temp'⎕ns'' ⍝ temp space
1 disp 2 3⍴#(⎕or'disp')⎕tc ⍬ '' (⎕or'temp') ⍝ some tricky cases.
┌→┬───────┬────────┐
↓#│ ∇disp │ │
│ │ │ │
│ │ │ │
├─┼∇──────┼───────→┤
│0│ │ #.temp │
└⊖┴──────⊖┴∇───────┘
⍕1 disp¨(⍳0)(2 0⍴0) ⍝ Roger's example.
⍕0 1 disp¨ ⊂3 2⍴ 0 1 ⍬ 3 ⍬ 5 ⍝ Roger's suggestion.
┌─┬─┐ ┌→┬─┐
│0│1│ ↓0│1│
├─┼─┤ ├─┼─┤
│ │3│ │0│3│
├─┼─┤ ├⊖┼─┤
│ │5│ │0│5│
└─┴─┘ └⊖┴─┘
⍕0 1 disp¨ ⊂⍳¨0 1 2 ⍝ undecorated: null item not exposed.
┌┬─┬───┐ ┌→┬─┬───┐
││1│1 2│ │0│1│1 2│
└┴─┴───┘ └⊖┴→┴~─→┘
⍕0 1 disp¨ ⊂((⍳2 2)-⍳1)⍴¨88 ⍝ null cols and rows.
┌┬──┐ ┌→┬──┐
├┼──┤ ↓0⌽0 ⌽
││88│ ├⊖┼~→┤
└┴──┘ │0↓88↓
└⊖┴~→┘
⍕0 1 disp¨ ⊂(0 3)(3 0)⍴¨⊂⊂⍬ ⍝ awkward cases.
┌────┬┐ ┌→──────┬───┐
│ ││ │┌→┬─┬─┐│┌⊖┐│
│ ││ │⌽0│0│0││↓0││
│ ││ │└⊖┴⊖┴⊖┘│├⊖┤│
│ ││ │ ││0││
│ ││ │ │├⊖┤│
│ ││ │ ││0││
│ ││ │ ⌽└⊖┘↓
└────┴┘ └──────→┴──⊖┘
disp 0 0⍴⊂⍬ ⍝ no boxing of prototypical item.
opts ← ⎕io<⍳2 2 ⍝ all option perms.
labs ← 'decorated, ' 'centred' ⍝ option labels.
stuff ← '' 'like this'(3 0⍴'') ⍝ content of all but top left cell.
tag←{∊((~⍺)/¨⊂'un'),¨⍵} ⍝ 'un' prefix where appropriate.
⍕opts {⍺ disp 2 2⍴(⊂⍺ tag ⍵),stuff}¨ ⊂labs
┌──────────────────────┬┐ ┌────────────────────┬┐
│undecorated, uncentred││ │undecorated, centred││
├──────────────────────┼┤ ├────────────────────┼┤
│like this ││ │ ││
│ ││ │ like this ││
│ ││ │ ││
└──────────────────────┴┘ └────────────────────┴┘
┌→───────────────────┬─┐ ┌→─────────────────┬─┐
↓decorated, uncentred│ │ ↓decorated, centred│ │
├───────────────────→┼⊖┤ ├─────────────────→┼⊖┤
│like this │ │ │ │ │
│ │ │ │ like this │ │
│ │ ↓ │ │ ↓
└───────────────────→┴⊖┘ └─────────────────→┴⊖┘
1 1 disp ⍳3 0 2 ⍝ null case with gaps.
┌→────┬─────┐
⌽0 0 0│0 0 0│
└~───→┴~───→┘
┌→────┬─────┐
⌽0 0 0│0 0 0│
└~───→┴~───→┘
┌→────┬─────┐
⌽0 0 0│0 0 0│
└~───→┴~───→┘
⍕∘.{disp ⍺ ⍵⍴⊂⍬}⍨ 2 1 0 ⍝ [10999]
┌┬┐ ┌┐
│││ ││
├┼┤ ├┤
│││ ││
└┴┘ └┘
┌┬┐ ┌┐
│││ ││
└┴┘ └┘
⍕∘.{1 disp ⍺ ⍵⍴⊂⍬}⍨ 2 1 0 ⍝ same again but with decoration.
┌→┬─┐ ┌→┐ ┌⊖┐
↓0│0│ ↓0│ ↓0│
├⊖┼⊖┤ ├⊖┤ ├⊖┤
│0│0│ │0│ │0│
└⊖┴⊖┘ └⊖┘ └⊖┘
┌→┬─┐ ┌→┐ ┌⊖┐
↓0│0│ ↓0│ ↓0│
└⊖┴⊖┘ └⊖┘ └⊖┘
┌→┬─┐ ┌→┐ ┌⊖┐
⌽0│0│ ⌽0│ ⌽0│
└⊖┴⊖┘ └⊖┘ └⊖┘
⍝∇ disp
Back to: code
Back to: Workspaces