TestPage2

A) Title level 2

     Prim←{(2=+⌿0=v∘.|v)/v←⍳⍵}

    83=⎕DR⊃⍵:{
         1=⍴,⍵:(1=⊃⍵)(0 0⍴0)(#.⎕NL 2 3 4)
         (1=⊃⍵)(0 0⍴0)(uMAT 2⊃2↑⍵)
     }⍵
     0(0 0⍴0)(uMAT ⍵)            ⍝default: Case sensitive

B) Title level 2

display←{⎕IO ⎕ML←0                          ⍝ Boxed display of array.

     ⍺←1 ⋄ chars←⍺⊃'..''''|-' '┌┐└┘│─'       ⍝ ⍺: 0-clunky, 1-smooth.

     tl tr bl br vt hz←chars                 ⍝ Top left, top right, ...

     box←{                                   ⍝ Box with type and axes.
         vrt hrz←(¯1+⍴⍵)⍴¨vt hz              ⍝ Vert. and horiz. lines.
         top←(hz,'⊖→')[¯1↑⍺],hrz             ⍝ Upper border with axis.
         bot←(⊃⍺),hrz                        ⍝ Lower border with type.
         rgt←tr,vt,vrt,br                    ⍝ Right side with corners.
         lax←(vt,'⌽↓')[¯1↓1↓⍺],¨⊂vrt         ⍝ Left side(s) with axes,
         lft←⍉tl,(↑lax),bl                   ⍝ ... and corners.
         lft,(top⍪⍵⍪bot),rgt                 ⍝ Fully boxed array.
     }

     deco←{⍺←type open ⍵ ⋄ ⍺,axes ⍵}         ⍝ Type and axes vector.
     axes←{(-2⌈⍴⍴⍵)↑1+×⍴⍵}                   ⍝ Array axis types.
     open←{(1⌈⍴⍵)⍴⍵}                         ⍝ Expose null axes.
     trim←{(~1 1⍷∧⌿⍵=' ')/⍵}                 ⍝ Remove extra blank cols.
     type←{{(1=⍴⍵)⊃'+'⍵}∪,char¨⍵}            ⍝ Simple array type.
     char←{⍬≡⍴⍵:hz ⋄ (⊃⍵∊'¯',⎕D)⊃'#~'}∘⍕     ⍝ Simple scalar type.

     {                                       ⍝ Recursively box arrays:
         0=≡⍵:' '⍪(⎕FMT ⍵)⍪(⊃⍵ ⍵∊⎕AV)⊃' -'   ⍝ Simple scalar.
         1 ⍬≡(≡⍵)(⍴⍵):'∇' 0 0 box ⎕FMT ⍵     ⍝ Object rep: ⎕OR.
         1=≡⍵:(deco ⍵)box open ⎕FMT open ⍵   ⍝ Simple array.
         ('∊'deco ⍵)box trim ⎕FMT ∇¨open ⍵   ⍝ Nested array.
     }⍵
 }


CategoryTest

TestPage2 (last edited 2014-10-22 13:44:31 by anonymous)