displayr←{⎕IO ⎕ML←0 1 ⍝ Boxed display of array box←{ ⍝ box with type and axes vrt hrz←(¯1+⍴⍵)⍴¨'│─' ⍝ vert. and horiz. lines top←(1+⍴hrz)↑(⊃(¯1↑⍺)⌷'─⊖',⊂⍕¯1↑1⊃⍺),hrz ⍝ upper border with axis bot←(⍴top)↑(⊃2↓⍺),hrz ⍝ lower border with type rgt←'┐│',vrt,'┘' ⍝ right side with corners lax←(⊃¨(¯1↓3↓⍺)⌷¨(-1⌈¯1+⍴1⊃⍺)↑(⊂'│⌽'),¨⊂∘⍕¨¯1↓0,1⊃⍺),¨⊂vrt ⍝ left side(s) with axes, lax←(⊂1+⍴vrt)↑¨(lax~¨⊂' '),¨'│' ⍝ pad and trim lft←⍉'┌',(↑lax),'└' ⍝ ... and corners lft,(top⍪⍵⍪bot),rgt ⍝ fully boxed array } deco←{⍺←type open ⍵ ⋄ (⍴⍴⍵),(⊂⍴⍵),⍺,axes ⍵} ⍝ type and axes vector axes←{(-2⌈⍴⍴⍵)↑1+×⍴⍵} ⍝ array axis types open←{16::(1⌈⍴⍵)⍴⊂'[ref]' ⋄ (1⌈⍴⍵)⍴⍵} ⍝ exposed null axes trim←{(~1 1⍷∧⌿⍵=' ')/⍵} ⍝ removal of extra blank cols type←{{(1=⍴⍵)⊃'+'⍵}∪,char¨⍵} ⍝ simple array type char←{⍬≡⍴⍵:'─' ⋄ (⊃⍵∊'¯',⎕D)⊃'#~'}∘⍕ ⍝ simple scalar type { ⍝ recursively boxed arrays: 0=≡⍵:' '⍪(open ⎕FMT ⍵)⍪(' '=⊃0⍴⍵)⊃' -' ⍝ simple scalar 1 ⍬≡(≡⍵)(⍴⍵):''(0 0)'∇' 0 0 box ⎕FMT ⍵ ⍝ object rep: ⎕OR 1=≡⍵:(deco ⍵)box open' ',⎕FMT open ⍵ ⍝ simple array ((⊂⍕≡⍵)deco ⍵)box trim' ',⎕FMT ∇¨open ⍵ ⍝ nested array }⍵ } code_colours test script Back to: notes Back to: Workspaces