bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improvements to gnuapl


From: Christian Robert
Subject: Re: Improvements to gnuapl
Date: Tue, 23 Feb 2021 05:54:05 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

All thoses request are based on the following piece of code i saw in 2004 (in 
nars2000):

      ⎕cr '#BoxFMT'
Z←Z #BoxFMT R;RD;LD;D
LD←⍕(0≠⍴⍴R)/¯1↑⍴R
RD←⍕⍪¯1↓⍴R
RD←(+/RD=' ')⌽RD
D←¯2+⍴⍴Z
:if D>0
:while 2<⍴⍴Z
  Z←,[¯3 ¯2] Z,[¯2]' '
:endwhile
Z←(-D)↓[0]Z
:endif
Z←(¯2↑1,⍴Z)⍴Z ⋄ Z←((⍴Z)⌈(¯1↑⍴RD),⍴LD)↑Z
:if 1≥⍴⍴R
  RD←((1↑⍴Z),1)⍴'│'
:else
  RD←⍉(1↑⍴Z)↑[1] RD ⋄ RD[(,RD=' ')/,⍳⍴RD]←'│'
:endif
RD←'┬'⍪RD⍪'┴' ⋄ RD[0 ¯1;0]←'┌└'
Z←Z,'│'
D←≡R
:if 1<D
  D←⍕D
  Z[⍳-⍴D;¯1]←⌽D
:endif
Z←'─'⍪Z⍪'─'
Z[0 ¯1;¯1]←'┐┘'
Z[0;⍳⍴LD]←LD
Z[¯1;0]←Type
Z←RD,Z

      ⎕cr '#MonFMT'
Z←#MonFMT R;⎕IO;Type;Lft;Top;Proto;A;⎕FEATURE
⎕IO←0 ⋄ ⎕FEATURE[0]←1
:if 1<≡R
  Type←'∊'
:else
  :if 0∊⍴R
    Proto←↑R
  :else
    Proto←R
  :endif
  Type←(0 ' '∊⊤Proto)/'~─¯'[0,1+0∊⍴R]
  :select ×/⍴Type
  :case 1
    Type←⍬⍴Type
  :case 2
    Type←'+'
  :endselect
:endif
Proto←0
:if 1≥≡Z←1/R
  :if 0=⍴⍴R
    Z←⍕Z ⋄ Z←(1,⍴Z)⍴Z
    :if Type='─'
      Z←Z⍪'¯'
    :elseif Type='~'
      Z←Z⍪'~'
    :endif
    :return
  :endif
  Z←((-2⌈⍴⍴Z)↑1,⍴Z)⍴Z←⍕Z
  :if 0∊⍴R
    Z←1 1⍴' 0'[Type='~']
  :endif
  Z←Z #BoxFMT R
:else
  :if 0∊⍴R
    Z←#MonFMT↑R
    Z←Z #BoxFMT R
  :else
    Z←''
    :forlcl I :in R
      A←#MonFMT I
      :if 0=≡I
        A←' '⍪A
      :endif
      Z←Z,⊂A
    :endforlcl
    :if 1=⍴⍴R
      Z←0 ¯1↓⊃,/(∊⌈/⍴¨Z)[0]↑[0]¨Z,¨' '
    :else
      Z←⊃(⍴R)⍴Z
    :endif
    Z←((-3⌈⍴⍴Z)↑1,⍴Z)⍴Z
    Z←(((¯3↓⍴Z),(⍴Z)[¯2],×/(⍴Z)[¯3 ¯1])⍴,[¯2 ¯3] Z) #BoxFMT R
  :endif
:endif


if you try to translate that to plain APL goto's
you will end up with an uncomprehensible spagetti of code, no Joke, i tryed.


Xtian.

ps: it's not my code but

it is doing something like in gnuapl: "24 Quad-CR var"

⎕FEATURE[0]←1  allow negative index to reach from the end of the array and 
below.  btw



reply via email to

[Prev in Thread] Current Thread [Next in Thread]