⍝ Boxed display of array:
display 'ABC'(1 4⍴1 2 3 4)(0 1 0⍴0)(⎕SE #)('88',99)
┌→────────────────────────────────────────┐
│ ┌→──┐ ┌→──────┐ ┌┌⊖┐ ┌→───────┐ ┌→────┐ │
│ │ABC│ ↓1 2 3 4│ ⌽↓0│ │ ⎕SE # │ │88 99│ │
│ └───┘ └~──────┘ └└~┘ └#───────┘ └+────┘ │
└∊────────────────────────────────────────┘
display 2 2⍴'Tea'(2 1⍴4 2)'&'(2 40)
┌→─────────────┐
↓ ┌→──┐ ┌→┐ │
│ │Tea│ ↓4│ │
│ └───┘ │2│ │
│ └~┘ │
│ ┌→───┐ │
│ & │2 40│ │
│ - └~───┘ │
└∊─────────────┘
display (15⍴1)⍴1
┌┌┌┌┌┌┌┌┌┌┌┌┌┌→┐
↓↓↓↓↓↓↓↓↓↓↓↓↓↓1│
└└└└└└└└└└└└└└~┘
display (15⍴0 1)⍴'a'
┌┌┌┌┌┌┌┌┌┌┌┌┌┌⊖┐
⌽↓⌽↓⌽↓⌽↓⌽↓⌽↓⌽↓ │
└└└└└└└└└└└└└└─┘
display ⎕tc
┌→┐
│ │
│ │
│ │
└─┘
display ⎕tc,⊂''
┌→──────────┐
│ ┌⊖┐ │
│ │ │ │
│ - └─┘ │
│ - - │
└∊──────────┘
display,¨⎕tc
┌→────────────┐
│ ┌→┐ ┌→┐ ┌→┐ │
│ │ │ │ │ │ │ │
│ └─┘ │ │ │ │ │
│ └─┘ └─┘ │
└∊────────────┘
display,¨16↑⎕av
┌→────────────────────────────────────────────────────────────────┐
│ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ ┌→┐ │
│ │ │ │ │ │ │ │ │ │ │ │
│ ││ ││ ││ │ │ │⌶│ │ɫ│ │%│ │'│ │⍺│ │⍵│ │
│ └─┘ └─┘ │ │ │ │ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ │
│ └─┘ └─┘ │
└∊────────────────────────────────────────────────────────────────┘
⍕display¨('88',99)(88,'99') ⍝ ambiguous cases.
┌→────┐ ┌→────┐
│88 99│ │88 99│
└+────┘ └+────┘
'temp'⎕ns'' ⍝ temp space
display 2 3⍴#(⎕or'display')⎕tc ⍬ '' (⎕or'temp') ⍝ some tricky cases.
┌→───────────────────────────────────────────────────────────────────────────────────────────────┐
↓ ┌───────────────────────────────────────────────────────────────────────────────┐ ┌→┐ │
│ # │ ∇display←{⎕IO ⎕ML←0 1 ⍝ Boxed display of array. │ │ │ │
│ │[1] │ │ │ │
│ │[2] box←{ ⍝ box with type and axes │ │ │ │
│ │[3] vrt hrz←(¯1+⍴⍵)⍴¨'│─' ⍝ vert. and horiz. lines │ └─┘ │
│ │[4] top←'─⊖→'[¯1↑⍺],hrz ⍝ upper border with axis │ │
│ │[5] bot←(⊃⍺),hrz ⍝ lower border with type │ │
│ │[6] rgt←'┐│',vrt,'┘' ⍝ right side with corners │ │
│ │[7] lax←'│⌽↓'[¯1↓1↓⍺],¨⊂vrt ⍝ left side(s) with axes, │ │
│ │[8] lft←⍉'┌',(↑lax),'└' ⍝ ... and corners │ │
│ │[9] lft,(top⍪⍵⍪bot),rgt ⍝ fully boxed array │ │
│ │[10] } │ │
│ │[11] │ │
│ │[12] deco←{⍺←type open ⍵ ⋄ ⍺,axes ⍵} ⍝ type and axes vector │ │
│ │[13] axes←{(-2⌈⍴⍴⍵)↑1+×⍴⍵} ⍝ array axis types │ │
│ │[14] open←{16::(1⌈⍴⍵)⍴⊂'[ref]' ⋄ (1⌈⍴⍵)⍴⍵} ⍝ exposure of null axes │ │
│ │[15] trim←{(~1 1⍷∧⌿⍵=' ')/⍵} ⍝ removal of extra blank cols│ │
│ │[16] type←{{(1=⍴⍵)⊃'+'⍵}∪,char¨⍵} ⍝ simple array type │ │
│ │[17] char←{⍬≡⍴⍵:'─' ⋄ (⊃⍵∊'¯',⎕D)⊃'#~'}∘⍕ ⍝ simple scalar type │ │
│ │[18] line←{(6≠10|⎕DR' '⍵)⊃' -'} ⍝ underline for atom │ │
│ │[19] │ │
│ │[20] { ⍝ recursive boxing of arrays:│ │
│ │[21] 0=≡⍵:' '⍪(open ⎕FMT ⍵)⍪line ⍵ ⍝ simple scalar │ │
│ │[22] 1 ⍬≡(≡⍵)(⍴⍵):'∇' 0 0 box ⎕FMT ⍵ ⍝ object rep: ⎕OR │ │
│ │[23] 1=≡⍵:(deco ⍵)box open ⎕FMT open ⍵ ⍝ simple array │ │
│ │[24] ('∊'deco ⍵)box trim ⎕FMT ∇¨open ⍵ ⍝ nested array │ │
│ │[25] }⍵ │ │
│ │[26] } │ │
│ │ ∇ │ │
│ └∇──────────────────────────────────────────────────────────────────────────────┘ │
│ ┌⊖┐ ┌⊖┐ ┌──────┐ │
│ │0│ │ │ │#.temp│ │
│ └~┘ └─┘ └∇─────┘ │
└∊───────────────────────────────────────────────────────────────────────────────────────────────┘
⍝∇ display
Back to: code
Back to: Workspaces