home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / teach.zip / UTILITY.ATF < prev   
Text File  |  1997-08-15  |  104KB  |  1,271 lines

  1. XNÉIO 0 1                                                                      °
  2. XNÉCT 0 1.000000000000001E²13                                                  °
  3. XCÉFC 1 6 .,*?_-                                                               °
  4. XNÉRL 0 577258720                                                              °
  5. XCÉPR 0                                                                        °
  6. XCÉLX 1 2 lx                                                                   °
  7. *(1996 4 6 16 8 39 356)                                                        °
  8.  FBIND ÉFX 'BIND' 'Σ Binding rules of APL2'                                    °
  9.   '''  1. Brackets bind to the left'''                                         °
  10.   '''  2. Left arrow binds to the left'''                                      °
  11.   '''  3. Dyadic operator binds to the right'''                                °
  12.   '''  4. Strand notation binding'''                                           °
  13.   '''  5. Operator binds to its left'''                                        °
  14.   '''  6. Function binds to its left'''                                        °
  15.   '''  7. Function binds to its right'''                                       °
  16. X '''  8. Left arrow binds to its right'',r'                                   °
  17. *(1997 7 13 12 28 47 496)                                                      °
  18.  FDISPLAY ÉFX 'D╜S DISPLAY A;ÉIO;R;C;HL;HC;HT;HB;VL;VB;V;W;N;B'                °
  19.   'Σ DISPLAY A GENERAL ARRAY IN PICTORIAL FORM'                                °
  20.   'Σ  NORMAL CALL IS MONADIC.  DYADIC CALL USED ONLY IN'                       °
  21.   'Σ    RECURSION TO SPECIFY DISPLAY RANK, SHAPE, AND DEPTH.' 'ÉIO╜0'          °
  22.   '»(0=ÉNC ''S'')/''S╜µA''' 'R╜╞µ,S                   Σ PSEUDO RANK.'          °
  23.   'C╜''┐┌└┘''                 Σ UR, UL, LL, AND LR CORNERS.'                   °
  24.   'HL╜''─''                   Σ HORIZONTAL LINE.'                              °
  25.   'HC╜HL,''Θ╕'',HL,''~+ε''      Σ HORIZONTAL BORDERS.'                         °
  26.   'HT╜HC[(0<R)⌡1+0<╞²1╞,S]' 'ΣW╜,0╧■╞0µΓ(1⌐µA)╞A'                              °
  27.   'HB╜HC[3+3╛(''2⌡~A╧«A'' ÉEA ''1+╞ε0⌡(1⌐⌡/µA)╞,A'')+3⌡1<µµS]'                 °
  28.   'VL╜''│''                   Σ VERTICAL LINE.'                                °
  29.   'VB╜VL,''Φ╟''               Σ VERTICAL BORDER.'                              °
  30.   'V╜VB[(1<R)⌡1+0<²1╞²1╟,S]'                                                   °
  31.   '»(0εµA)/''A╜(1⌐µA)µΓ╞A''   Σ SHOW PROTOTYPE OF EMPTIES.'                    °
  32.   '╕(1<╧A)/GEN' '╕(2<µµA)/D3'                                                  °
  33.   'D╜«A                     Σ SIMPLE ARRAYS.' 'W╜1╞µD╜(²2╞1 1,µD)µD'           °
  34.   'N╜²1+1╟µD' '╕(0=µµA)/SS'                                                    °
  35.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  36.  3]' '╕0' 'SS:HB╜((0 '' '')=╞0µΓA)/'' -'''                                     °
  37.   'D╜'' '',('' '',[0]D,[0]HB,Nµ'' ''),'' ''' '╕0'                              °
  38.   'GEN:D╜«DISPLAY■A          Σ ENCLOSED ...' 'N╜Dδ.⌠'' '''                     °
  39.   'D╜(Nδ~1ΦN)≡D' 'D╜(δ≡~''  ''╤D)/D' 'D╜((1,µS)µS)DISPLAY D'                   °
  40.   '╕(2≥µ,S)╟D3E,0' 'D3:D╜0 ²1╟0 1╟«ΓA         Σ MULT-DIMENSIONAL ...'          °
  41.   'W╜1╞µD' 'N╜²1+1╟µD'                                                         °
  42.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  43.  3]' 'D3E:N╜²2+µ,S'                                                            °
  44. X 'V╜C[Nµ1],[0]VB[1+0<²2╟,S],[0](((²3+╞µD),N)µVL),[0]C[Nµ2]' 'D╜V,D'           °
  45. *(1997 7 28 13 40 53 632)                                                      °
  46.  FEXIT ÉFX 'EXIT' 'Σ Exit from function'                                       °
  47.   '''To log off type:'',r,''    )OFF'',r'                                      °
  48.   '''You can also log off by clicking on the LOG pull down menu and'''         °
  49.   '''selecting QUIT. (This process may cause a CONTINUE workspace to be'       °
  50. X'' '''saved.)''' '╕'                                                          °
  51. *(1997 7 28 13 37 49 604)                                                      °
  52.  FEXIT╢ ÉFX 'EXIT╢' 'Σ Z V Jizba, July 28, 1997'                               °
  53.   '''Function EXIT tells the student how to log off, and clears the'''         °
  54. X '''state indicator.''' 'endd'                                                °
  55. *(1997 7 13 12 28 48 500)                                                      °
  56.  FGO ÉFX 'GO;T;E;B' 'Σ Expression driver' 'L0:B╜E╜''''' 'æ╜''      '''         °
  57.   'T╜æ' '╕(^/'' ''=T)/L0' '╕((^/'')OFF ''=5╞6╟T)doif ''EXIT'')/0'              °
  58.   '╕(('':''εT)doif ''B╜evaldd (+/^\'''' ''''=T)╟T'')/L0'                       °
  59.   '''E╜ÉEM'' ÉEA T' '╕(0=µ,E)/L0' '╕B/L0'                                      °
  60.   '''This is not a valid APL2 expression''' 'æ╜''*'''                          °
  61. X '╕(''?''⌠╞1╟æ)/L0' 'E' '╕L0'                                                 °
  62. *(1997 7 28 13 43 20 512)                                                      °
  63.  FHELP ÉFX 'HELP;N;I;T' 'Σ Help to student' '''WHAT TO DO'',r'                 °
  64.   '''  ° To get out of the lesson''' '''       ENTER: EXIT'''                  °
  65.   '''  ° To log off APL2'''                                                    °
  66.   '''       FIRST, ENTER: EXIT  THEN ENTER: )OFF'''                            °
  67.   '''  ° To get help''' '''       ENTER: HELP'''                               °
  68.   '''  ° When you see a prompt'''                                              °
  69.   '''       ENTER AN APL2 EXPRESSION - OR JUST PRESS: ENTER''' 'do'            °
  70.   '''  ° If you get this line'',r'                                             °
  71.   '''This is not a valid APL2 expression'',r,''*'',r'                          °
  72.   '''        YOU CAN EITHER''' '''           A. PRESS: ENTER'''                °
  73.   '''           B. PRESS: ? and then ENTER to see what was incorrect'''        °
  74.   '''              in your expression causing that response'',r' 'do'          °
  75.   'Σ''HINTS'',r'                                                               °
  76.   'Σ''This lesson is made up of '',(«N╜6),'' components named TEACH*A, w       °
  77.  here''' 'Σ''the * stands for one or two digit in the range 1-22:'',r'         °
  78.   'ΣI╜0' 'ΣL0:T╜''TEACH'',(«I╜I+1)' 'ΣT,'' '',1╟(ÉCR T)[2;]'                   °
  79.   'Σ╕(N>I)/L0' 'Σdo'                                                           °
  80.   'Σ''You may review either of these components separately. To do that,'       °
  81.  ''                                                                            °
  82.   'Σ''first enter EXIT (and RETURN), then enter the name of the lesson.'       °
  83.  '' 'Σ''component (e.g. TEACH4).'',r'                                          °
  84.   'Σ''To re-start the lesson, just enter TEACH'',r'                            °
  85.   '''When the screen fills up, it is a good idea to move the cursor to''       °
  86.  ' '''the start of a convenient paragraph, and press ENTER'',r'                °
  87.   '''You may also wish to press PAGE UP to review the previous pages.'''       °
  88.   'do' '''RESOURCES'',r'                                                       °
  89.   '''You may also enter ONE of the following words at a time'',r'              °
  90.   '''BIND           To display APL2 binding rules'''                           °
  91.   '''DISPLAY array  To display APL2 array structure'''                         °
  92.   '''EXIT           To exit from execution (same as ╕)'''                      °
  93.   '''GO             To allow usage of direct definitons'',r'                   °
  94.   '''     also'',r'                                                            °
  95. X '''number TIME expression -- to estimate execution time''' 'endd'            °
  96. *(1997 5 31 11 59 20 572)                                                      °
  97.  FRULE ÉFX 'V RULE W' 'Σ Display rules' '╕(2=ÉNC ''V'')/L0'                    °
  98. X '2 rule W ╪ ╕0' 'L0:V rule W'                                                °
  99. *(1997 7 13 12 28 49 504)                                                      °
  100.  FTIME ÉFX 'U╜V TIME W;T' 'Σ Measure execution time of W'                      °
  101. X 'U╜60 60 1000¥²3╞ÉTS' 'T╜»■VµΓW' 'U╜(,-U-60 60 1000¥²3╞ÉTS)÷V'               °
  102. *(1997 7 13 12 28 49 504)                                                      °
  103.  Faddquote ÉFX 'u╜addquote w'                                                  °
  104.   'Σ Put quotes around a string, and double existing quotes'                   °
  105. X 'u╜ÉAV[40],((1+w=ÉAV[40])/w),ÉAV[40]'                                        °
  106. *(1997 7 28 12 52 59 700)                                                      °
  107.  Faddquote╢ ÉFX 'addquote╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'              °
  108.   '''Function "addquote" is monadic and produces a result. It takes'''         °
  109.   '''a character string right argument, and returns it with a leading'''       °
  110.   '''and trailing quote. Any quote(s) in the string will be doubled.'',r       °
  111.  '                                                                             °
  112.   'show ''''''ONE'''''' ''addquote ''''ONE'''''' '''''''''''''''''''' ''       °
  113.  addquote '''''''''''''''''''                                                  °
  114.   '''When a character string in quotes is evaluated, APL2 returns that''       °
  115.  '                                                                             °
  116.   '''string without quotes (first example). Applying addquote to that'''       °
  117.   '''same string, the quotes are retained (example 2). A single quote'''       °
  118.   '''is described by four quotes: leading and trailing quotes to define'       °
  119.  ''                                                                            °
  120.   '''a string, and two quotes to define a quote (example 3). Example 4''       °
  121. X' '''shows addquote returning the string defining a single quote.'''          °
  122. *(1997 7 24 13 20 38 476)                                                      °
  123.  Fav ÉFX 'av;A;N;I;ÉIO' 'Σ Display characters in ÉAV' 'ÉIO╜0'                  °
  124.   'A╜22 78µ'' ''' 'N╜3 0«φ12 22µ1+∞356' 'A[;,(6⌡∞12)°.+2 3 4]╜N'               °
  125.   'A[;6+6⌡∞12]╜φ12 22µÉAV' 'ΣA[8 10 13;6]╜'' ''' 'A[13;6]╜'' '''               °
  126. X 'A[14+∞8;68 69 70 72]╜'' ''' 'A'                                             °
  127. *(1997 7 28 12 53 9 504)                                                       °
  128.  Fav╢ ÉFX 'av╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                          °
  129.   '''Function "av" displays the 256 characters in ÉAV, the ATOMIC VECTOR       °
  130.  ''' 'show ''av'''                                                             °
  131.   '''The symbol for ÉAV[14] represents a line feed. It is made blank to        °
  132.  avoid'''                                                                      °
  133.   '''a disruption in the table. ÉAV[33] is the blank character.'''             °
  134. X 'endd'                                                                       °
  135. *(1991 11 11 8 25 13 316)                                                      °
  136.  Fdate ÉFX 'u╜date w' 'Σ Format date and time of day' 'u╜«6╞w'                 °
  137. X 'u╜('' ''⌠u)Γu' 'u╜εu,■''-- .. '''                                           °
  138. *(1997 7 31 13 0 3 284)                                                        °
  139.  Fdate╢ ÉFX 'date╢' 'Σ Copyright Z V Jizba, 1994'                              °
  140.   '''APL2 System Variable ÉTS returns an integer vector specifying the''       °
  141.  '                                                                             °
  142.   '''current date and time. When a user defined function is displayed us       °
  143.  ing'''                                                                        °
  144.   '''the del (╖) symbol, the IBM software supplies a time stamp listing'       °
  145.  ''                                                                            °
  146.   '''the date and time in a more readable format. The year, month and da       °
  147.  y'''                                                                          °
  148.   '''are separated by a dash, and the hour, minute and second are separa       °
  149.  ted'''                                                                        °
  150.   '''by the period. Function "date" converts a numeric vector into this'       °
  151.  ''                                                                            °
  152.   '''format. It is useful in the simulation of function listing through'       °
  153.  '' '''function "showfn".'',r' 'show ''ÉTS'' ''date ÉTS'''                     °
  154.   '''The function does not require the right argument to contain any'''        °
  155.   '''numbers, but if it does not the right argument should be prepared''       °
  156.  ' '''with some care.'',r' 'show ''date ∞0'' ''date 0 ''''ABC'''''''           °
  157.   '''THE ALGORITHM'',r' '(0 0 1 2 showfn ''date''),r'                          °
  158.   '''On line [2] only the first 6 elements of the right argument are'''        °
  159.   '''selected, and are formatted. Note that this line would cause'''           °
  160.   '''certain arguments containing characters to fail'',r'                      °
  161.   'show ''DISPLAY «6╞0 ''''abc'''' ''''def'''' ''''g'''' ''''h'''' ''''i       °
  162.  ''''''' '''To get around this problem, one can enter'',r'                     °
  163.   'show ''date ,■''''year'''' ''''month'''' ''''day'''' ''''h'''' ''''m'       °
  164.  ''' ''''s''''''' '(0 3 4 showfn ''date''),r'                                  °
  165.   '''On line [3] the six numeric values are extracted as nested vectors.       °
  166.  '''                                                                           °
  167.   '''On line [4] the dashes a blank and periods are inserted, and the'''       °
  168.   '''result is converted to a simple vector, which is returned by the'''       °
  169. X '''function.''' 'endd'                                                       °
  170. XCdig 1 10 1234567890                                                          °
  171. *(1997 7 3 12 47 22 432)                                                       °
  172.  Fdisclaimer ÉFX 'disclaimer' 'Σ Copyright statement'                          °
  173.   '(10µ'' ''),''Copyright, Z. V. Jizba, 1995,1996,1997'',r'                    °
  174.   ''' This and subsequent workspaces labelled TEACHxx are made available       °
  175.  '''                                                                           °
  176.   '''at no cost to anyone who desires to learn how to use effectively'''       °
  177.   '''the IBM/OS2 version of APL2.'',r'                                         °
  178.   '''This software is provided "AS IS" with no WARRANTY of any kind, eit       °
  179.  her'''                                                                        °
  180.   '''express or implied. Any risk in its use resides with you, the user        °
  181. Xof''' '''these tutorials.''' '''(PRESS ENTER to continue)'''                  °
  182. *(1997 7 26 13 11 27 404)                                                      °
  183.  Fdisclaimer╢ ÉFX 'disclaimer╢' 'Σ Z V Jizba, July 26, 1997'                   °
  184.   '''Function "disclaimer" displays the copyright notice and informatiom       °
  185.  '''                                                                           °
  186.   '''about the conditions under which the APL2OS2 tutorials can be used.       °
  187. X''' 'endd'                                                                    °
  188. *(1997 7 13 12 28 50 508)                                                      °
  189.  Fdo ÉFX 'do;T;E' 'Σ Expression driver' 'E╜''''' 'æ╜''      ''' 'T╜æ'          °
  190.   '╕(^/'' ''=T)/0'                                                             °
  191.   '╕(('':''εT)doif ''B╜evaldd (+/^\'''' ''''=T)╟T'')/2'                        °
  192.   '''E╜ÉEM'' ÉEA T' '╕(0=µ,E)/2'                                               °
  193.   '''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/2'        °
  194. X 'E' '╕2'                                                                     °
  195. *(1997 7 13 12 28 50 508)                                                      °
  196.  Fdoif ÉFX 'U╢╜V╢ doif W╢;t╢' 'Σ Rule' '╕(^/~U╢╜V╢)/0'                         °
  197. X '''U╢╜V╢ doif■ W╢'' ÉEA ''»V╢/W╢'''                                          °
  198. *(1997 7 28 12 53 50 668)                                                      °
  199.  Fdoif╢ ÉFX 'doif╢;T' 'Σ Z V Jizba, UTILITY, April 6, 1991'                    °
  200.   '''Function "doif" is a utility to provide conditional evaluation of''       °
  201.  '                                                                             °
  202.   '''expressions. The left argument is an expression that must return a'       °
  203.  ''                                                                            °
  204.   '''boolean value. This could be a scalar or a vector. If it is a vecto       °
  205.  r,'''                                                                         °
  206.   '''it must have the same length as the left argument, which then must'       °
  207.  ''                                                                            °
  208.   '''be nested. The right argument is one or more character strings. The       °
  209.  se'''                                                                         °
  210.   '''should be valid APL2 expressions. The function returns the result o       °
  211.  f''' '''evaluating the left argument.''' 'do'                                 °
  212.   '''If the left argument returns a zero, the function returns zero, and       °
  213.  ''' '''the right argument is ignored'',r' 'show ''0 doif ''''∞5'''''''        °
  214.   '''If the left argument returns a one, the right argument is evaluated       °
  215.  '',r' 'show ''1 doif ''''∞5'''''''                                            °
  216.   '''If the right argument contains more than one expression, these will       °
  217.  '''                                                                           °
  218.   '''be evaluated after reduction by the left argument boolean vector'',       °
  219.  r' 'show ''1 doif ''''T╜3'''' ''''T╜4'''' ''''∞■T'''''''                      °
  220.   'show ''T╜1 0 1 doif ''''T╜3'''' ''''T╜4'''' ''''∞■∞T'''''' ''T'''           °
  221.   '''Notice that the function returns a vector if the right argument is        °
  222.  a''' '''vector'',r'                                                           °
  223.   'show ''DISPLAY 0 1 1 doif ''''T╜3'''' ''''T╜4'''' (''''∞T'''' ''''∞■∞       °
  224.  T'''')'''                                                                     °
  225.   '''Function "doif" assigns the result to local header variable U╢. In'       °
  226.  ''                                                                            °
  227.   '''some applications it may be desirable to return a result from the''       °
  228.  '                                                                             °
  229.   '''right argument, rather than the default boolean vector. This can be       °
  230.  ''' '''accomplished by assigning a right hand expression to U╢'',r'           °
  231.   'show ''T╜1 0 1 doif ''''U╢╜3'''' ''''T╜4'''' ''''∞■∞T'''''' ''T'''          °
  232.   '''Function "doif" was originally developed for an early version of AP       °
  233.  L'''                                                                          °
  234.   '''that did not support the "diamond" (╪). User defined functions can'       °
  235.  ''                                                                            °
  236.   '''now use the diamond to provide some of the functionality of "doif".       °
  237.  '''                                                                           °
  238.   '''However, there are applications, where expressions may be stored in       °
  239.  '''                                                                           °
  240.   '''character arrays to be retrieved in a random way. There, the functi       °
  241. Xon''' '''"doif" may still be useful.''' 'endd'                                °
  242. *(1997 7 28 12 54 31 596)                                                      °
  243.  Fdo╢ ÉFX 'do╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                          °
  244.   '''Function "do" simulates the APL2 prompt. If the keyboard entry is''       °
  245.  ' '''Enter, or all blanks followed by Enter, the function exits.'',r'         °
  246.   'show ''0 3 4 5 showfn ''''do'''''''                                         °
  247.   '''If a non blank line is entered, and if it contains at least one col       °
  248.  on,'''                                                                        °
  249.   '''then an attempt is made to evaluate it as a direct definition'',r'        °
  250.   'show ''0 6 showfn ''''do'''''''                                             °
  251.   '''(The leading blanks are removed first. See also documentation'''          °
  252.   '''of functions doif and evaldd)''' 'do'                                     °
  253.   '''Else the line is evaluated as a valid APL2 expression'',r'                °
  254.   'show ''0 2 7 8 showfn ''''do'''''''                                         °
  255.   '''The error message is not displayed at first. Instead, another'''          °
  256.   '''message merely states that the expression is not valid, and a line'       °
  257.  ''                                                                            °
  258.   '''with * is made available as a prompt. Any expression on this line''       °
  259.  '                                                                             °
  260.   '''other than one beginning with ? returns to the start. The ? causes'       °
  261.  '' '''the ERROR MESSAGE to be displayed'',r'                                  °
  262.   'show ''0 9 10 11 12 showfn ''''do'''''''                                    °
  263.   '''To test this function, first enter ÉLC. This will give you the curr       °
  264.  ent''' '''LINE COUNT. Then enter'',r' '''      do'',r'                        °
  265.   '''and again try ÉNC to show 7 indicating you are evaluating line'''         °
  266.   '''7 of function do. You can try to evaluate valid and invalid APL2'''       °
  267.   '''expressions (System commands will be treated as invalid). Also test       °
  268.  '''                                                                           °
  269.   '''the ERROR MESSAGE by entering ''''?''''. Finally, enter a blank lin       °
  270.  e to'''                                                                       °
  271.   '''exit ''''do''''. Then enter ÉLC to verify you are out of the functi       °
  272. Xon.''' 'endd'                                                                 °
  273. *(1997 7 25 12 51 38 600)                                                      °
  274. XFendd ÉFX 'endd' 'Σ end of special feature' '20µ''²''' 'Σdo'                  °
  275. *(1997 7 25 12 58 51 680)                                                      °
  276.  Fendd╢ ÉFX 'endd╢;T' 'Σ Z V Jizba, UTILITY, April 6, 1991'                    °
  277.   '''This function prints a line of 20 bars (and pauses for user input)'       °
  278.  '' 'showfn ''endd'''                                                          °
  279.   '''It is used at the end of documentation functions such as HELP to'''       °
  280.   '''indicate their completion. (The example below illustrates its usage       °
  281.  '''                                                                           °
  282.   '''to indicate the end of this documentation.) The pause (function "do       °
  283.  ")'''                                                                         °
  284.   '''is commented out in this workspace. In the tutorials the pause give       °
  285.  s'''                                                                          °
  286.   '''the student one last chance to try out expressions that may rely on       °
  287.  ''' '''local variables present in the expository function.'',r'               °
  288. X 'show ''endd'''                                                              °
  289. *(1997 7 24 13 13 50 496)                                                      °
  290.  Ferase ÉFX 'erase;t;EXIT;GO;HELP;DISPLAY;BIND;REVIEW;RULE;TIME'               °
  291.   'Σ Erase all global functions and variables' 't╜ÉNL 3'                       °
  292.   't╜(~t^.εlc,'' ╢'')≡t' 't╜ÉEX(~t[;∞5]^.=''TEACH'')≡t' 't╜ÉNL 2'              °
  293. X 't╜ÉEX(~t^.εlc,'' ╢'')≡t' 't╜ÉNL 4' 't╜ÉEX(~t^.εlc,'' ╢'')≡t'                °
  294. *(1997 7 28 12 58 5 508)                                                       °
  295.  Ferase╢ ÉFX 'erase╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                    °
  296.   '''Function "erase " will erase all APL2 objects from the workspace th       °
  297.  at'''                                                                         °
  298.   '''may have been generated during its usage. The function is niladic''       °
  299.  ' '''and consists of the following steps:'',r'                                °
  300.   '''  1  Remove all functions except those in lower case, those'''            °
  301.   '''     listed in the header, and those named TEACH*. (Here * has'''         °
  302.   '''     the same meaning as in DOS)'''                                       °
  303.   '''  2  Remove all variables except those in lower case and any'''           °
  304.   '''     defined in the header.'''                                            °
  305.   '''  2  Remove all defined operators except those in lower case and'''       °
  306.   '''     any defined in the header.'',r'                                      °
  307.   'show ''Ab╜∞5'' ''ÉFX ''''U╜FOO'''' ''''U╜∞5'''''' ''ÉFX ''''U╜(f OP)        °
  308.  W'''' ''''U╜∞5''''''' 'show ''ÉNC■''''Ab'''' ''''FOO'''' ''''OP'''''''        °
  309.   'show ''erase''' 'show ''ÉNC■''''Ab'''' ''''FOO'''' ''''OP'''''''            °
  310.   '''NOTE: FUNCTION erase IN THIS WORKSPACE ONLY (UTILITY) ALLOWS NAMES'       °
  311. X'' '''      TO CONTAIN THE CHARACTER ╢.''' 'endd'                             °
  312. *(1997 8 4 12 17 23 324)                                                       °
  313.  Ferrors ÉFX 'errors W;EC;RT;R' 'Σ Display error message'                      °
  314.   '╕((1<╧W)doif ''errors■ W'')/0' '''       '',W' '(EC RT R)╜ÉEC W' 'R'        °
  315. X 'do'                                                                         °
  316. *(1997 8 4 12 16 56 452)                                                       °
  317.  Ferrors╢ ÉFX 'errors╢;T;E' 'Σ Z V Jizba, UTILITY, August 4, 1997'             °
  318.   'E╜Γ[2]ÉCR ''errors'' ╪ T╜ÉFX 6╞E'                                           °
  319.   '''Function "errors" is used in the tutorials to display error message       °
  320.  s'''                                                                          °
  321.   '''caused by invalid APL2 expressions. This function uses the Execute'       °
  322.  ''                                                                            °
  323.   '''Controlled System command to extract the error message, avoiding an       °
  324.  ''' '''interrupt. The function is monadic'',r'                                °
  325.   'show ''errors ''''∞∞'''''''                                                 °
  326.   '''When the expression "errors ''''∞∞''''" is evaluated (first line),        °
  327.  the'''                                                                        °
  328.   '''expression "∞∞" is displayed first (second line). This is followed'       °
  329.  '' '''by the error message (last three lines).'',r'                           °
  330.   'show ''errors ''''∞5'''''''                                                 °
  331.   '''When the right argument to the "errors" function is a valid express       °
  332.  ion,'''                                                                       °
  333.   '''the result of that expression is displayed instead of an error mess       °
  334. Xage.''' 'T╜ÉFX E' 'showfn ''errors''' 'endd'                                  °
  335. *(1996 4 6 15 59 49 596)                                                       °
  336.  Fevaldd ÉFX 'u╜evaldd w;c;n' 'Σ Evaluate direct definition' 'u╜0'             °
  337.   'n╜(w∞''Σ'')-1' 'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w'                    °
  338.   '╕(label╞c)/0' '╕((2=µc)doif ''u╜showdd 1╙c'')/0'                            °
  339.   '╕((3=ÉNC╞c)doif ''u╜⌡µÉ╜(╞c),'''' is already defined.'''''')/0'             °
  340.   '╕((3=µc)doif ''u╜simdd c'')/0' 'c╜(Γ''α∙ aw'')replace■c'                    °
  341.   'u╜ε''u╜'',((''a''εεc[2 3 4])/''a ''),(╞c),'' w;t;b'''                       °
  342.   'u╜u(5πc)(''b╜(t╜'',(3πc),'')/'',addquote ''u╜'',4πc)'                       °
  343. X 'u╜u,''╕(t doif b)/0''(''u╜'',2πc)' 'u╜╧ÉFX u'                               °
  344. *(1997 7 28 13 4 52 484)                                                       °
  345.  Fevaldd╢ ÉFX 'evaldd╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991'              °
  346.   '''Function "evaldd" is normally used as a subroutine of function "do"       °
  347.  .'''                                                                          °
  348.   '''It is invoked whenever the string entered at the terminal contains'       °
  349.  ''                                                                            °
  350.   '''a colon. The presence of a colon indicates the likelihood of a DIRE       °
  351.  CT'''                                                                         °
  352.   '''DEFINITION. Although this mode of function definition is not suppor       °
  353.  ted'''                                                                        °
  354.   '''by APL2, its usage in the APL literature calls for support in a tut       °
  355.  orial''' '''on the language.'',r'                                             °
  356.   '''Before we describe the nature of function "evaldd" we need to expla       °
  357.  in''' '''this concept of direct definition.''' 'do'                           °
  358.   '''     DIRECT DEFINITION'',r'                                               °
  359.   '''In APL2, user defined functions can be constructed using a built in       °
  360.  '''                                                                           °
  361.   '''EDITOR, or with the help of the FUNCTION DEFINITION MODE. For the''       °
  362.  '                                                                             °
  363.   '''later, the character ╖ is a toggle switch between this function'''        °
  364.   '''definition mode and APL2 execution mode. With direct definition (DD       °
  365.  ),'''                                                                         °
  366.   '''there should be no need for invoking the editor or for switching mo       °
  367.  des.'''                                                                       °
  368.   '''Functions could be defined in the execution mode. But there is a'''       °
  369.   '''limitation. The function to be defined must be expressible in ONE l       °
  370.  ine.'''                                                                       °
  371.   '''Function "evaldd" simulates the availability of direct definition b       °
  372.  y''' '''supporting its three formats:'',r'                                    °
  373.   '''      FUNNAME:expression'''                                               °
  374.   '''      FUNNAME:left-expression:condition:right-expression'''               °
  375.   '''      FUNNAME:'',r'                                                       °
  376.   '''The first two forms define a DD function. The third one displays'''       °
  377.   '''a previously defined direct definition. The defined function may be       °
  378.  '''                                                                           °
  379.   '''monadic or dyadic, and it will always produce a result. The right''       °
  380.  '                                                                             °
  381.   '''argument to the function is represented by the symbol ∙, and the'''       °
  382.   '''left argument by the symbol α.''' 'do'                                    °
  383.   '''In the first form (FUNNAME:expression), the function returns the'''       °
  384.   '''result of the expression. In the conditional form, (the second'''         °
  385.   '''expression) condition is evaluated first. It must return a boolean'       °
  386.  ''                                                                            °
  387.   '''scalar. If it is a one, then the right-expression will be evaluated       °
  388.  '''                                                                           °
  389.   '''and returned. If the condition returns a zero, then the left-expres       °
  390.  sion'''                                                                       °
  391.   '''will be evaluated and returned. Examples are given below.''' 'do'         °
  392.   '''      FUNCTION  evaldd'',r'                                               °
  393.   '''Normally, "evaldd" is invoked by functions "do" and "go" whenever a       °
  394.  '''                                                                           °
  395.   '''colon is detected in the string entered at the keyboard. Therefore,       °
  396.  '''                                                                           °
  397.   '''"evaldd" is monadic. The right argument is the string containing at       °
  398.  '''                                                                           °
  399.   '''least one colon. The function returns a one if the DD expression ha       °
  400.  s'''                                                                          °
  401.   '''been successfully completed. It returns a zero if the evaluation fa       °
  402.  ils.'',r' '''     '',4╟0 0 1 showfn ''evaldd'''                               °
  403.   '''Due to the nature of these APL2 tutorials, there are some extra'''        °
  404.   '''conditions that the right argument to "evaldd" must satisfy:'',r'         °
  405.   '''   1. Function to be defined must begin with an upper case letter''       °
  406.  ' '''   2. Comments (text following symbol Σ) is allowed'''                   °
  407.   '''   3. New function must not have the same name as that of a'''            °
  408.   '''      previously defined function.'',r' 'do'                              °
  409.   '0 2 3 4 5 showfn ''evaldd'''                                                °
  410.   '''Line [2] assigns 0 (fail) to the return variable. Line [3] finds'''       °
  411.   '''the location of the lamp (Σ) symbol, if it is present. Line [4]'''        °
  412.   '''first partitions the argument to the left of any Σ symbol'',r'            °
  413.   '''      (((n╞w)⌠'''':'''')Γn╞w)'',r'                                        °
  414.   '''Then it catenates the enclose of string "ΣDD", followed by any'''         °
  415.   '''comments. Line [5] uses utility "label" to test for presence'''           °
  416.   '''of a valid name (Start with an upper case letter). If this test fai       °
  417.  ls,''' '''"evaldd" exits.''' 'do' '0 6 7 8 showfn ''evaldd'''                 °
  418.   '''If the expression is of the form FUNNAME:, then line [6] calls'''         °
  419.   '''function "showdd" with FUNNAME as right argument (see showdd╢).'''        °
  420.   '''If FUNNAME already exists as a function, further processing is'''         °
  421.   '''aborted on line [7]. If the expression is of the form FUNNAME:exp,'       °
  422.  ''                                                                            °
  423.   '''then the nested vector c is sent to function "simdd" for final'''         °
  424.   '''processing (see simdd╢). If neither of these events take place, the       °
  425.  n'''                                                                          °
  426.   '''the direct definition is of the form FUNNAME:left:condition:right''       °
  427.  ,r' '0 9 showfn ''evaldd'''                                                   °
  428.   '''Line [9] replaces all ocurrences of α and ∙ by "a" and "w". This'''       °
  429.   '''means that these two letters should not be used as symbols in the''       °
  430.  '                                                                             °
  431.   '''DD expressions. (See replace╢ for explanation of this utility).'''        °
  432.   'do' '0 10 showfn ''evaldd'''                                                °
  433.   '''Line [10] generates a standard header'',r'                                °
  434.   '0 11 showfn ''evaldd'''                                                     °
  435.   '''On line [11] the header is followed by the comment line (5πc). Then       °
  436.  ''' '''the right-argument is extracted if condition is true'',r'              °
  437.   '0 12 showfn ''evaldd'''                                                     °
  438.   '''If true, evaluate right argument and exit, else evaluate left argum       °
  439.  ent'',r' '0 13 showfn ''evaldd'''                                             °
  440.   '''Finally the nested string generated in lines [10-12] is fixed. If''       °
  441.  '                                                                             °
  442.   '''the process works, ╧ÉFX will return a one, else it will return a'''       °
  443.   '''zero.''' 'do' '''EXAMPLES'',r'                                            °
  444.   'show ''evaldd ''''HELP:∞5  Σ A new function'''''''                          °
  445.   'show ''evaldd ''''help:∞5  Σ A new function'''''''                          °
  446.   'show ''evaldd ''''FOO:∞∙  Σ A new function'''''' ''1 showfn ''''FOO''       °
  447.  '''' ''FOO 5'''                                                               °
  448.   'show ''ÉEX ''''FOO'''''' ''evaldd ''''FOO:∞α:α<∙:∞∙  Σ Do the larger        °
  449.  integer''''''' 'show ''1 showfn ''''FOO'''''' ''4 FOO 6'' ''5 FOO 2'''        °
  450. X 'endd'                                                                       °
  451. *(1997 7 25 13 27 52 564)                                                      °
  452.  Fexit ÉFX 'V exit W;T' 'Σ Exit if too many suspended functions'               °
  453.   '╕(0⌠ÉNC ''V'')/L0 ╪ V╜10' 'L0:╕(V>µÉLC)/0'                                  °
  454.   '''There are too many suspended functions''' '''Please enter '',W'           °
  455. X '╕'                                                                          °
  456. *(1997 7 28 13 5 3 292)                                                        °
  457.  Fexit╢ ÉFX 'exit╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991'                  °
  458.   '''Some students may attempt to enter expressions that cause excessive       °
  459.  ly'''                                                                         °
  460.   '''long vector of suspended functions. For this reason many expository       °
  461.  '''                                                                           °
  462.   '''"TEACH*" functions invoke "exit" to test for this condition. The ri       °
  463.  ght'''                                                                        °
  464.   '''argument to "exit" in the tutorials is usually the string ''''TEACH       °
  465.  ..'''''''                                                                     °
  466.   '''In this way, the student is prompted to re-enter the proper APL2'''       °
  467.   '''expression to continue the tutorial after the line counter is clear       °
  468.  ed''' '''out.''' 'showfn ''exit'''                                            °
  469.   '''The optional left argument allows changing the default maximum leng       °
  470.  th''' '''(10) of the  line counter'',r'                                       °
  471.   'show ''ÉFX ''''FOO'''' ''''ÉLC'''' ''''1 exit ''''''''endd'''''''''''       °
  472.  ' ''''do''''''' '1 showfn ''FOO'''                                            °
  473.   '''Note that after the message: Please enter: ..., you will no longer'       °
  474.  ''                                                                            °
  475.   '''be in execution mode [try any System Command such as )SI. It should       °
  476. X''' '''work at that point].'',r' 'show ''FOO''' 'endd'                        °
  477. *(1997 7 26 12 33 39 536)                                                      °
  478.  Fget ÉFX 'U╜V get W;t;T;ÉPR' 'Σ Prompt for response from keyboard'            °
  479.   'ÉPR╜T╜ÉAV[ÉIO+255] ╪ ╕(0⌠ÉNC ''V'')/L0 ╪ V╜1' 'L0:V╜V╧1' 'æ╜W ╪ t╜æ'        °
  480.   'U╜(+/^\t=T)╟t' '╕(''╕''⌠╞U)/L1 ╪ ╕' 'L1:╕V/0' 't╜(U⌠'' '')ΓU'               °
  481. X 'U╜(µt),(ΓU),t'                                                              °
  482. *(1997 7 28 13 14 2 324)                                                       °
  483.  Fget╢ ÉFX 'get╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                        °
  484.   '''Function "get" was designed to handle text processing. The objectiv       °
  485.  e'''                                                                          °
  486.   '''of this function is to display a prompt, and then accept text input       °
  487.  '''                                                                           °
  488.   '''from the terminal on the same line as the prompt. The right argumen       °
  489.  t'''                                                                          °
  490.   '''is the prompt. Normally, the function is invoked monadically.'''          °
  491.   '''A zero left argument, when present, will partition the user entry''       °
  492.  ' '''into an array of words, and return a nested vector with'''               °
  493.   '''  1. The number of words in the user entry'''                             °
  494.   '''  2. The original user entry'''                                           °
  495.   '''  3.... The partitioned user entry'',r'                                   °
  496.   '''You may backspace into the prompt, but it is NOT recommended. If yo       °
  497.  u'''                                                                          °
  498.   '''backspace into the prompt and then enter text, each time your text'       °
  499.  ''                                                                            °
  500.   '''character matches the prompt character the space will be filled out       °
  501.  '''                                                                           °
  502.   '''by the Prompt Replacement symbol. In the following two examples,'''       °
  503.   '''after backspacing, enter two or three words, and in one of the'''         °
  504.   '''examples re-enter a word having at least one letter the same as tha       °
  505.  t''' '''of the underlying prompt'',r'                                         °
  506.   'show ''DISPLAY get ''''Backspace, then enter a short phrase: '''''''        °
  507.   'show ''DISPLAY 0 get ''''Backspace, then enter a short phrase: ''''''       °
  508.  ' 'showfn ''get'''                                                            °
  509.   '''On line [2] the last character of the Atomic vector is assigned as        °
  510.  a'''                                                                          °
  511.   '''prompt replacement. If the left argument is missing, the default is       °
  512.  '''                                                                           °
  513.   '''set to 1. Line [3] insures that V is a boolean scalar. Line [4]'''        °
  514.   '''displays the prompt and places user input into local variable "t".'       °
  515.  ''                                                                            °
  516.   '''Line [5] rejects the initial string of T''''s (ÉAV[256]) from strin       °
  517.  g "t"''' '''and assigns the result to U.'',r'                                 °
  518.   '''In line [6] if the first character in "t" is a branch (╕), escape''       °
  519.  '                                                                             °
  520.   '''(i.e. Clear the state indicator). If on line [7] V=1 exit. Else, ''       °
  521.  '                                                                             °
  522.   '''if V is 0, partition the user entry into words [8] and place into U       °
  523.  '''                                                                           °
  524.   '''the number of words, the user entry, and the nested vector of words       °
  525. X.''' 'endd'                                                                   °
  526. *(1997 7 28 13 33 8 424)                                                       °
  527.  Fglobals ÉFX 'globals' 'Σ Initialize useful global variables'                 °
  528.   'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''                                          °
  529.   'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890'''                     °
  530. X 'r╜ÉAV[13+ÉIO]' 'q╜'''''''''                                                 °
  531. *(1997 7 28 13 34 33 528)                                                      °
  532.  Fglobals╢ ÉFX 'globals╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                °
  533.   '''Function "globals" is normally used by a workspace initializing fun       °
  534.  ction'''                                                                      °
  535.   '''to establish certain (lower case) variables as global to the'''           °
  536.   '''workspace. These globals are of the type that may be used by other'       °
  537.  '' '''APL2 functions'',r' '''GLOBAL    CONTENTS'''                            °
  538.   '''   q      single quote'''                                                 °
  539.   '''   r      New line (return character)'''                                  °
  540.   '''  uc      Upper case letters''' '''  lc      Lower case letters'''        °
  541. X '''  dig     Digits'',r' 'show ''uc ╪ lc ╪ r ╪ q,dig,q''' 'endd'             °
  542. *(1997 7 3 12 47 6 368)                                                        °
  543.  Finitialize ÉFX 'initialize;T' 'Σ Initialize workspace'                       °
  544.   '''AT ALL TIMES, TO CONTINUE, PRESS RETURN!'',r'                             °
  545.   '''To see disclaimers enter:'',r,''    disclaimer''' 'do' 'erase'            °
  546.   'globals'                                                                    °
  547.   '''Make sure the CAP LOCK light on your keyboard (upper right) is ON!'       °
  548. X'' 'endd'                                                                     °
  549. *(1997 7 28 13 17 39 484)                                                      °
  550.  Finitialize╢ ÉFX 'initialize╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'          °
  551.   '''Function "initialize" is a prototype of a defined function that can       °
  552.   be'''                                                                        °
  553.   '''used as the latent variable of the workspace. It is niladic and pro       °
  554.  duces'''                                                                      °
  555.   '''no result, but it resets the environment of the workspace to its'''       °
  556.   '''start condition. The function does the following:'',r'                    °
  557.   '''   1. Instructs the user on how to proceed'''                             °
  558.   '''   2. Tels how to obtain copyright and warning note'''                    °
  559.   '''   3. All APL2 objects not belonging to the workspace are erased'''       °
  560.   '''   4. All global variables are re-defined'''                              °
  561.   '''   5. The user is asked to press the CAPS LOCK key.'''                    °
  562.   '''      The "Caps Lock" should be set to ON to insure that any'''           °
  563.   '''      assignments made by the student will be in CAPS. (Function'''       °
  564.   '''      "erase" will erase ALL but some selected names in CAPS.'',r'        °
  565.   '''This function can be used directly (ÉLX╜''''initialize''''), or can       °
  566.   be'''                                                                        °
  567.   '''incorporated in another defined function or expression to be used a       °
  568. Xs''' '''the latent variable.''' 'do' 'showfn ''initialize''' 'endd'           °
  569. *(1997 7 27 13 14 33 444)                                                      °
  570.  Flabel ÉFX 'u╜v label w'                                                      °
  571.   'Σ Return 1 if label w does not begin with a cap'                            °
  572.   '╕(0⌠ÉNC ''v'')/L0 ╪ v╜0' 'L0:v╜v╧1 ╪ w╜εw ╪ ╕v/L1 ╪ ╕(u╜0⌠ÉNC w)/0'         °
  573. X 'L1:╕(u╜~^/wεlc,uc,dig)/0' 'u╜w[1]εlc,dig'                                   °
  574. *(1997 7 28 13 18 45 512)                                                      °
  575.  Flabel╢ ÉFX 'label╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                    °
  576.   '''Function "label" is ambivalent. It returns a boolean value. The rig       °
  577.  ht'''                                                                         °
  578.   '''argument is presumed to be a rank-0 depth-1 character vector. If'''       °
  579.   '''it is a valid APL2 label, is not already defined in the workspace,'       °
  580.  ''                                                                            °
  581.   '''and does not begin with a lower case letter, the function will'''         °
  582.   '''return a zero. Else, the function will return a 1.'',r'                   °
  583.   'show ''label ''''TEST'''' ╪ label ''''tEST23'''' ╪ label ''''3test'''       °
  584.  ''''                                                                          °
  585.   'show ''label ''''TEST_TWO'''' ╪ label ''''DISPLAY'''' ╪ label ''''tes       °
  586.  t'''''''                                                                      °
  587.   '''In the examples above only the first one is acceptable.'',r'              °
  588.   '''If a left argument is given, it should be a 1. When present, it cau       °
  589.  ses''' '''the test for Name Class to be omitted.'',r'                         °
  590.   'show ''1 label ''''DISPLAY'''''''                                           °
  591.   '''This function is used in some tutorials to insure that the student        °
  592.  will'''                                                                       °
  593.   '''name APL2 objects in a manner that will avoid conflicts. Furthermor       °
  594.  e,'''                                                                         °
  595.   '''it insures that these labels will be erased by utility function "er       °
  596.  ase".''' 'showfn ''label'''                                                   °
  597.   '''Line [2] assigns a zero to "v" if the left argument is absent. Line       °
  598.  '''                                                                           °
  599.   '''[3] insures the left argument to be boolean, and the right argument       °
  600.  '''                                                                           °
  601.   '''to be enlisted. If v=1, the Name Class test is omitted. Line [4]'''       °
  602.   '''rejects the label if it contains special characters, and line [5]''       °
  603.  '                                                                             °
  604.   '''rejects the label if the first character is a digit or lower case''       °
  605. X' '''letter.''' 'endd'                                                        °
  606. XClc 1 26 abcdefghijklmnopqrstuvwxyz                                           °
  607. *(1997 8 15 12 37 24 452)                                                      °
  608.  Flx ÉFX 'lx' 'Σ Latent variable for UTILITY workspace'                        °
  609.   '''Functions in lower case are utility functions. Some of these'''           °
  610.   '''utilities are described in the tutorials. Functions in upper case''       °
  611.  '                                                                             °
  612.   '''are considered to contain tutorial text. (Exception:DISPLAY is an''       °
  613.  ' '''IBM copyrighted utility.)'',r'                                           °
  614.   '''To find out what functions are available, enter'',r,''      )FNS'',       °
  615.  r'                                                                            °
  616.   '''To find out what variables are available, enter'',r,''      )VARS''       °
  617.  ,r'                                                                           °
  618.   '''There are no defined operator utilities in this workspace. Any'''         °
  619.   '''function name ending with ╢ is a documentation function. Entering''       °
  620.  '                                                                             °
  621.   '''this label (including ╢) will describe that function. Variables in'       °
  622.  ''                                                                            °
  623.   '''lower case may be displayed direcly. These are self explanatory, bu       °
  624.  t''' '''you may also enter: globals╢.'',r'                                    °
  625.   '''Lower case functions not described here, should not be considered''       °
  626.  ' '''as part of the utility set.'',r'                                         °
  627.   '''The first 8 tutorial workspaces summarize the APL2 grammar and'''         °
  628.   '''syntax by listing a set of rules. These rules can be accessed in'''       °
  629.   '''this utility workspace by entering:'',r' '''      1 RULE n'',r'           °
  630.   '''where n is the rule number (from 1 to 35). The remaining workspaces       °
  631.  '''                                                                           °
  632.   '''(TEACH9 through TEACH22) deal with the APL2 syntax in a different w       °
  633.  ay.'''                                                                        °
  634.   '''There is a set of "binding rules" that fully defines the APL2 synta       °
  635.  x.''' '''To get a listing of these binding rules, enter'',r'                  °
  636. X '''    BIND'',r' 'endd'                                                      °
  637. *(1997 7 13 12 28 55 528)                                                      °
  638.  Fnon ÉFX 'non;T;RC;ET;R' 'Σ Ignore keyboard entry' 'æ╜''      ''' 'T╜æ'       °
  639.   '╕(0=µ(T⌠'' '')/T)/0' '(RC ET R)╜ÉEC T' '╕(0=RC)/2'                          °
  640. X '╕((1=RC)doif ''R'')/2' '╕2'                                                 °
  641. *(1997 7 27 12 49 55 668)                                                      °
  642.  Fnon╢ ÉFX 'non╢;TEST' 'Σ Z V Jizba, UTILITY, April 6, 1991'                   °
  643.   '''Function "non" is used in tutorials at places where invalid APL2'''       °
  644.   '''expressions are to be ignored. Valid APL2 expressions, however,'''        °
  645.   '''are evaluated normally'',r'                                               °
  646.   '''In the following invocation of "non", first enter ∞5, then try'''         °
  647.   '''TEST╜∞5. Then enter some nonsense text, and then just press Enter''       °
  648.  ' '''(twice!) to exit this documentation.'',r' 'show ''non'''                 °
  649.   'showfn ''non'''                                                             °
  650.   '''The function is similar to function "do". When an error is detected       °
  651. X,''' '''unlike "do" it just ignores that expression.''' 'endd'                °
  652. *(1997 7 13 12 28 55 528)                                                      °
  653.  Fnotb ÉFX 'u╜notb w' 'Σ Remove trailing blanks'                               °
  654.   '╕((1<╧w)doif ''u╜notb■ w'')/0' '╕((1<µµw)doif ''u╜πnotb Γ[2]w'')/0'         °
  655. X 'u╜(1-(,'' ''⌠Φw)∞1)╟w'                                                      °
  656. *(1997 7 27 12 52 23 552)                                                      °
  657.  Fnotb╢ ÉFX 'notb╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                      °
  658.   '''Function "notb" is monadic, and produces a result'',r'                    °
  659.   '²24╞4╟0 0 showfn ''notb'''                                                  °
  660.   '''The right argument is presumed to be a vector, a nested vector or''       °
  661.  '                                                                             °
  662.   '''a character array of rank 2. The result is an object of the same'''       °
  663.   '''shape, rank and depth but with excess trailing blanks removed.'''         °
  664.   'do' '''EXAMPLES:'',r' 'show ''DISPLAY notb ''''ONE TWO     '''''''          °
  665.   'show ''DISPLAY notb ''''ONE   '''' ''''TWO   '''' ''''   '''''''            °
  666.   'show ''DISPLAY notb (2 4µ''''ONE TWO ''''),2 5µ'''' '''''''                 °
  667. X 'showfn ''notb''' 'endd'                                                     °
  668. *(1997 7 27 12 55 6 496)                                                       °
  669.  Fproblems ÉFX 'problems' 'Σ Problems'                                         °
  670.   '''That is all for this lesson. Remember, if you want to practice,'''        °
  671.   '''and plan to use direct definitions, be sure to first enter GO.'''         °
  672.   '''Direct definitions will then be accepted. To exit GO, enter EXIT.''       °
  673.  ,r'                                                                           °
  674.   '''To erase a previously defined DIRECT DEFINITION FUNCTION, enter'',r       °
  675.  ' '''       )ERASE functionname'',r'                                          °
  676. X '''WARNING! do not use )ERASE on other labels.'',r'                          °
  677. *(1997 7 28 13 27 6 392)                                                       °
  678.  Fproblems╢ ÉFX 'problems╢' 'Σ Z V Jizba, July 28, 1998'                       °
  679.   '''This utility is used to indicate the end of a tutorial lesson.'''         °
  680.   '''Should the student try to save the workspace, it gives instruction'       °
  681.  ''                                                                            °
  682.   '''on how to erase any APL2 objects generated by the student should'''       °
  683.   '''the student choose to do so. (On loading the workspace, function'''       °
  684.   '''"erase" will do that as well).'',r'                                       °
  685.   '''This function will also instruct the student to invoke function'''        °
  686. X '''GO if the use of Direct Definitions is desired.''' 'endd'                 °
  687. XCq 0 '                                                                        °
  688. XCr 0                                                                         °
  689. *(1997 7 13 12 28 56 532)                                                      °
  690.  Freplace ÉFX 'u╜v replace u;i;r;s' 'Σ Replace elements in v in u'             °
  691.   'i╜Γ∞µu' 's╜2πv╜(v⌠'' '')Γv' 'i╜⌡r╜i⌡■Γ[1]u°.=╞v'                            °
  692. X 'u[(εi)/εr]╜s[(εi)/εi⌡■∞µs]'                                                 °
  693. *(1997 7 27 12 56 29 592)                                                      °
  694.  Freplace╢ ÉFX 'replace╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                °
  695.   '''Function "replace" is used to replace selected characters in the ri       °
  696.  ght'''                                                                        °
  697.   '''argument. The characters to be replaced, and their replacements are       °
  698.  '''                                                                           °
  699.   '''specified in the left argument. The two parts are separated by a'''       °
  700.   '''blank'',r' '²24╞4╟0 0 showfn ''replace'''                                 °
  701.   '''Note that the right argument label is the same as that of the resul       °
  702.  t.''' '''The right argument should be a character vector'',r'                 °
  703.   '0 2 showfn ''replace'''                                                     °
  704.   '''First, a scalar is generated containing the numeric count of the'''       °
  705.   '''components of the right argument''' 'do' '0 3 showfn ''replace'''         °
  706.   '''Next, the elements of the left argument are extracted (locals s and       °
  707.   v)''' 'do' '0 4 showfn ''replace'''                                          °
  708.   '''The position and identity of the symbols to be replaced are stored        °
  709.  in''' '''variables i and r''' 'do' '0 5 showfn ''replace'''                   °
  710.   '''Finally the replacements are made'',r' '''EXAMPLES:'',r'                  °
  711.   'show ''''''OT AB'''' replace ''''ONE TWO THREE'''''''                       °
  712.   '''The function was designed to be used in the replacement of α and ∙'       °
  713.  '' '''in DIRECT DEFINITION'',r'                                               °
  714. X 'show ''π(Γ''''au α∙'''') replace■ Γ[2]ÉCR ''''replace''''''' 'endd'         °
  715. *(1997 7 13 12 28 56 532)                                                      °
  716.  Fround ÉFX 'U╜V round W' 'Σ Half adjust to V th decimal'                      °
  717. X 'U╜(╛0.5+W⌡10*V)÷10*V'                                                       °
  718. *(1997 7 27 13 0 3 268)                                                        °
  719.  Fround╢ ÉFX 'round╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                    °
  720.   '''Function "round" half adjusts the right argument at the position of       °
  721.  ''' '''specified by the left argument'',r'                                    °
  722.   'show ''0 round 123.456'' ''²2 round 12345.6'' ''3 round 123.456789'''       °
  723.   'show ''2 round É╜0.0001⌡?5µ100000'''                                        °
  724.   'show ''2 round É╜2 4µ0.0001⌡?8µ100000'''                                    °
  725. X 'show ''²2 round É╜Γ[2]2 4µ?8µ100000''' 'showfn ''round''' 'endd'            °
  726. *(1997 6 5 13 40 14 380)                                                       °
  727.  Frule ÉFX 'V rule W' 'Σ Additional remarks on rules'                          °
  728.   '╕(2=ÉNC ''V'')/L ╪ V╜0' 'L:╕(~(╞W)ε∞8)/LA ╪ V rulea╞W ╪ ╕L0'                °
  729.   'LA:╕(~(╞W)ε9 10 11)/LB ╪ V ruleb╞W ╪ ╕L0'                                   °
  730.   'LB:╕(~(╞W)ε11+∞8)/LC ╪ V rulec╞W ╪ ╕L0'                                     °
  731.   'LC:╕(~(╞W)ε19+∞10)/LD ╪ V ruled╞W ╪ ╕L0'                                    °
  732.   'LD:╕(30 31 32 33 34 35=╞W)/L30,L31,L32,L33,L34,L35'                         °
  733.   '''This rule number is undefined'' ╪ ╕' '╕(0=V)/L0' 'L30:╕(V>1)/L30X'        °
  734.   '''    RULE 30. The length of left argument to both TAKE and DROP must       °
  735.  '''                                                                           °
  736.   '''            equal the rank of the right argument. The exception: a'       °
  737.  ''                                                                            °
  738.   '''            scalar left argument can be applied to a right argument       °
  739.  ''' '''            vector.'',2µr' '╕(0=V)/L0'                                 °
  740.   'L30X:''A zero is permissible on both take and drop. A null vector is        °
  741.  not.''' '╕L0' 'L31:╕(V>1)/L31X'                                               °
  742.   '''   RULE 31. For TAKE and DROP with axis specification, every'''           °
  743.   '''            integer in the left argument must be matched with'''          °
  744.   '''            a valid axis in brackets. Axes may not be duplicated.''       °
  745.  '                                                                             °
  746.   '''            The length of the left argument may be less than the'''       °
  747.   '''            rank of the right argument with axis specification.'',2       °
  748.  µr' '╕(0=V)/L0' 'L31X:''Any axes not specified are left unchanged.'''         °
  749.   '╕L0' 'L32:╕(V>1)/L32X'                                                      °
  750.   '''   RULE 32. Monadic Take extracts the contents of the first scalar'       °
  751.  ''                                                                            °
  752.   '''            (rank 0 array) in an array, regardless of its rank.'''        °
  753.   '''            It is called FIRST.'',2µr' '╕(0=V)/L0'                        °
  754.   'L32X:''The FIRST of an empty array returns the prototype.''' '╕L0'          °
  755.   'L33:╕(V>1)/L33X'                                                            °
  756.   '''   RULE 33. The each operator can be placed to the right of a'''          °
  757.   '''            function, or to the right of an operator. When used,'''       °
  758.   '''            it applies the combined function separately to every'''       °
  759.   '''            element of the argument.'',2µr' '╕(0=V)/L0'                   °
  760.   'L33X:''This operator is so powerful that it is tempting to over-use i       °
  761.  t.'''                                                                         °
  762.   '''As you excercise your APL2 skills, try to solve problems without'''       °
  763.   '''the EACH operator as much as possible.''' '╕L0' 'L34:╕(V>1)/L34X'         °
  764.   '''   RULE 34. A rank 0 array, or another array can be catenated to an       °
  765.  '''                                                                           °
  766.   '''            array. When two arrays are catenated, the matching dime       °
  767.  nsion''' '''            of the two arrays must be the same.'',2µr'            °
  768.   '╕(0=V)/L0'                                                                  °
  769.   'L34X:''Catenation does not increase depth. The result will have the d       °
  770.  epth''' '''of the component of greatest depth.'',r'                           °
  771.   'show ''╧3 3µ∞9'' ''╧Γ∞5'' ''╧(3 3µ∞9),Γ∞5''' '╕L0' 'L35:╕(V>1)/L35X'        °
  772.   '''   RULE 35. Two arrays can be catenated if their rank differs by 1.       °
  773.  '''                                                                           °
  774.   '''            The shapes of dimensions not catenated MUST MATCH!'',2µ       °
  775.  r' '╕(0=V)/L0'                                                                °
  776.   'L35X:''Naturally, to catenate along other than the last dimension, an       °
  777.   axis''' '''specification can also be used here.''' 'L0:do'                   °
  778. X '╕(0=µW╜1╟W)/0' '╕L'                                                         °
  779. *(1997 6 1 12 42 53 524)                                                       °
  780.  Frulea ÉFX 'V rulea W' 'Σ Additional remarks on rules'                        °
  781.   '╕(2=ÉNC ''V'')/L ╪ V╜0' 'L:╕(W=∞8)/L1,L2,L3,L4,L5,L6,L7,L8'                 °
  782.   '''For rules not described in this lesson, see workspace INDEX'''            °
  783.   '╕0' 'L1:╕(V>1)/L1X'                                                         °
  784.   '''RULE 1. For arithmetic operations a vector must be matched with a''       °
  785.  ' '''        scalar, or another vector of the same length.'',2µr'             °
  786.   '╕(0=V)/0'                                                                   °
  787.   'L1X:''This is the first of many rules dealing with the concept of'''        °
  788.   '''CONFORMABILITY. This means that elements to be processed by APL2'''       °
  789.   '''must in some ways match.''' '╕0' 'L2:╕(V>1)/L1X'                          °
  790.   '''RULE 2. The reduction operator places the function, (specified to''       °
  791.  '                                                                             °
  792.   '''        its left), between all pairs of the vector. It then evaluat       °
  793.  es''' '''        the resulting expression.'',2µr' '╕(0=V)/0'                  °
  794.   'L2X:''There is more to this, but at this stage the rule is essentiall       °
  795.  y''' '''correct.''' '╕0' 'L3:╕(V>1)/L1X'                                      °
  796.   '''RULE 3. All APL2 expressions are evaluated from right to left'',2µr       °
  797.  ' '╕(0=V)/0'                                                                  °
  798.   'L3X:''This rule is valid in APL, which is the earlier version of APL2       °
  799.  .'''                                                                          °
  800.   '''For APL2, the rule has been restated in a totally different way.'''       °
  801.   '''However until we introduce some concepts that are new to APL2, the'       °
  802.  '' '''newer form reduces to RULE 3 as stated.''' '╕0' 'L4:╕(V>1)/L1X'         °
  803.   '''RULE 4. Vectors in APL2 can have lengths of zero and one.'',2µr'          °
  804.   '╕(0=V)/0'                                                                   °
  805.   'L4X:''This is the first concept that begins to introduce the idea tha       °
  806.  t no'''                                                                       °
  807.   '''matter what the APL expression, if it is valid, it must produce a''       °
  808.  '                                                                             °
  809.   '''valid APL2 object. (Shades of which came first, the chicken or the        °
  810.  egg)''' '╕0' 'L5:╕(V>1)/L1X'                                                  °
  811.   '''RULE 5. The shape of a variable is a vector. The shape of a vector'       °
  812.  '' '''        is a vector of length 1. The shape of a scalar is a'''          °
  813.   '''        vector of length zero.'',2µr' '╕(0=V)/0'                          °
  814.   'L5X:''The left argument of RESHAPE is by definition a vector. If APL2       °
  815.   is'''                                                                        °
  816.   '''to be internally consistent, the inverse operation to RESHAPE (whic       °
  817.  h''' '''is indeed SHAPE) MUST return the same type of object.''' '╕0'         °
  818.   'L6:╕(V>1)/L1X'                                                              °
  819.   '''RULE 6. Reduction of a scalar returns that scalar REGARDLESS of'''        °
  820.   '''        the function to the left of the reduction operator.'',2µr'        °
  821.   '╕(0=V)/0'                                                                   °
  822.   'L6X:''Reduction BY DEFINITION reduces the RANK by one. The exception        °
  823.  is'''                                                                         °
  824.   '''for objects whose rank is zero. Since there is no such thing as'''        °
  825.   '''negative rank, reduction is undefined for scalars, and therefore'''       °
  826.   '''the result is to leave the APL2 object unchanged.''' '╕0'                 °
  827.   'L7:╕(V>1)/L1X'                                                              °
  828.   '''RULE 7. The reduction of a null vector produces the identity'''           °
  829.   '''        element of the function.'',2µr' '╕(0=V)/0'                        °
  830.   'L7X:''A null vector may be empty, but it still has rank equal to one.       °
  831.  '''                                                                           °
  832.   '''Therefore its reduction MUST be a scalar. Since there is no data'''       °
  833.   '''in a null vector, the scalar must be such that it has no effect'''        °
  834.   '''on the operation performed by the function: Zero added to anything'       °
  835.  ''                                                                            °
  836.   '''has no effect in addition; one multiplied by anything has no effect       °
  837.  ''' '''in multiplication; and so on.''' '╕0' 'L8:╕(V>1)/L1X'                  °
  838.   '''RULE 8. Parentheses can (and should) be used to modify the right'''       °
  839.   '''        to left rule to improve efficiency'',2µr' '╕(0=V)/0'              °
  840.   'L8X:''Parentheses are used in APL2 for other purposes as well, but fo       °
  841.  r'''                                                                          °
  842.   '''now, we will use them just to modify the right to left rule (RULE 3       °
  843.  ).'''                                                                         °
  844.   '''If you place parentheses where they are not needed, APL2 will ignor       °
  845. Xe''' '''them.'''                                                              °
  846. *(1997 6 1 12 49 37 488)                                                       °
  847.  Fruleb ÉFX 'V ruleb W' 'Σ Additional remarks on rules'                        °
  848.   '╕(2=ÉNC ''V'')/L ╪ V╜0' 'L:╕(9 10 11=╞W)/L9,L10,L11 ╪ ╕0'                   °
  849.   'L9:╕(V>1)/L9X'                                                              °
  850.   '''   RULE 9: To produce a quote inside a character string, enter'''         °
  851.   '''           the quote twice.'',2µr' '╕(0=V)/0'                             °
  852.   'L9X:''This is used in most other programming languages.''' '╕0'             °
  853.   'L10:╕(V>1)/L10X'                                                            °
  854.   ''' RULE 10: In replication the left argument must contain only'''           °
  855.   '''          integers. The length of the left argument must be'''            °
  856.   '''          the same as the length of the right argument.'',2µr'            °
  857.   '╕(0=V)/0'                                                                   °
  858.   'L10X:''The left argument may also have negative integers. Only the nu       °
  859.  mber'''                                                                       °
  860.   '''of positive integers and zeros must add up to the length of the rig       °
  861.  ht'''                                                                         °
  862.   '''argument. Replicate with negative integers is not discussed here be       °
  863.  cause'''                                                                      °
  864.   '''the explanation requires concepts that have not yet been mentioned.       °
  865.  '',r' 'show ''1 1 2 ²1 0 1 1 1 ²1 1 0 1 1/''''CALIFORNIAN''''''' '╕0'         °
  866.   'L11:╕(V>1)/L11X'                                                            °
  867.   '''   RULE 11: The expression inside square brackets must return'''          °
  868.   '''            positive integers in the range of the length of'''            °
  869.   '''            the indexed vector. If the expression is MISSING,'''          °
  870.   '''            the result is as if the brackets were missing.'',2µr'         °
  871.   '╕(0=V)/0'                                                                   °
  872.   'L11X:''The expression in brackets need not be a vector. It could be a       °
  873.  n''' '''array as in the next example'',r'                                     °
  874. X 'show ''''''CALIFORNIA''''[3 3µ?9µ10]'' ''(∞4)[3 3µ∞4]'''                    °
  875. *(1997 6 2 12 11 17 260)                                                       °
  876.  Frulec ÉFX 'V rulec W' 'Σ Additional remarks on rules'                        °
  877.   '╕(2=ÉNC ''V'')/L ╪ V╜0'                                                     °
  878.   'L:╕((11+∞8)=╞W)/L12,L13,L14,L15,L16,L17,L18,L19' 'L12:╕(V>1)/L12X'          °
  879.   '''   RULE 12. A scalar function is one that will produce a result on'       °
  880.  ''                                                                            °
  881.   '''            every scalar element of a vector or array. EXAMPLES:'''       °
  882.   '''            + - ⌡ ÷ * are numeric scalar functions. , µ ∞ are NOT''       °
  883.  ' '''            scalar functions.'',r' '╕(0=V)/0'                            °
  884.   'L12X:''This distinction will become clearer when we study more genera       °
  885.  lized''' '''arrays.''' '╕0' 'L13:╕(V>1)/L13X'                                 °
  886.   '''   RULE 13. Scalars that work with vectors also work with arrays.''       °
  887.  ,r' '╕(0=V)/0'                                                                °
  888.   'L13X:''No problem with simple scalars, but this rule may need modific       °
  889.  ation'''                                                                      °
  890.   '''when we deal with "rank zero arrays" that are not simple scalars.''       °
  891.  ' '╕0' 'L14:╕(V>1)/L14X'                                                      °
  892.   '''   RULE 14. Arrays with the same shape can be processed with scalar       °
  893.  ''' '''functions.'',r' '╕(0=V)/0'                                             °
  894.   'L14X:''Arrays with distinct shapes can be processed as we shall see,        °
  895.  but'''                                                                        °
  896.   '''there will be restrictions, and we will use new operators.''' '╕0'        °
  897.   'L15:╕(V>1)/L15X'                                                            °
  898.   '''   RULE 15. The number of semicolons inside brackets must equal the       °
  899.  ''' '''            rank of the array MINUS 1.'',r' '╕(0=V)/0'                 °
  900.   'L15X:''There is no further generalization to this rule.''' '╕0'             °
  901.   'L16:╕(V>1)/L16X'                                                            °
  902.   '''   RULE 16. An axis specification can be a scalar, a vector or a'''       °
  903.   '''            null vector.'',r' '╕(0=V)/0'                                  °
  904.   'L16X:''Recall that null array is the ONLY bracket specification that'       °
  905.  ''                                                                            °
  906.   '''makes sense for a scalar. We will use that property when dealing wi       °
  907.  th''' '''rank 0 arrays.''' '╕0' 'L17:╕(V>1)/L17X'                             °
  908.   '''   RULE 17. An axis specification can be any array containing'''          °
  909.   '''            valid integers.'',r' '╕(0=V)/0'                               °
  910.   'L17X:''With this rule, you can generate an APL2 object of arbitrary''       °
  911.  ' '''rank.''' '╕0' 'L18:╕(V>1)/L18X'                                          °
  912.   '''   RULE 18. The shape of the result of axis specification is the'''       °
  913.   '''            catenation of the shapes of expressions inside brackets       °
  914.  .'''                                                                          °
  915.   '''            If the expression for an axis is missing, the shape for       °
  916.  ''' '''            that axis is unchanged.'',r' '╕(0=V)/0'                    °
  917.   'L18X:''This is merely the rule for implementation of rule 17.'''            °
  918.   '╕0' 'L19:╕(V>1)/L19X'                                                       °
  919.   '''   RULE 19. Simple reduction of arrays removes its last dimension.'       °
  920. X',r' '╕(0=V)/0' 'L19X:''This is a generalization of rule 2.''' '╕0'           °
  921. *(1997 6 3 12 4 29 284)                                                        °
  922.  Fruled ÉFX 'V ruled W' 'Σ Additional remarks on rules'                        °
  923.   '╕(2=ÉNC ''V'')/L ╪ V╜0'                                                     °
  924.   'L:╕(W=19+∞10)/L20,L21,L22,L23,L24,L25,L26,L27,L28,L29'                      °
  925.   '''This rule number is undefined'' ╪ ╕' 'L20:╕(V>1)/L20X'                    °
  926.   '''   RULE 20. The depth of an APL array is defined as the maximum'''        °
  927.   '''            depth to reach a simple scalar.'',2µr' '╕(0=V)/0'             °
  928.   'L20X:''The concept of depth provides the means of building complex da       °
  929.  ta'''                                                                         °
  930.   '''structures. This is the first of several rules dealing with depth.'       °
  931.  '' '╕0' 'L21:╕(V>1)/L21X'                                                     °
  932.   '''   RULE 21. No APL2 expression can generate a depth 1 object contai       °
  933.  ning'''                                                                       °
  934.   '''            ONLY a scalar. (Or, a scalar can not have depth 1.)'',2       °
  935.  µr' '╕(0=V)/0'                                                                °
  936.   'L21X:''This rule can be treated as an axiom of APL2. In theory it is'       °
  937.  ''                                                                            °
  938.   '''possible to enclose a scalar, but that would lead to a significantl       °
  939.  y'''                                                                          °
  940.   '''different language. EXAMPLE: The reduction of a vector must return'       °
  941.  ''                                                                            °
  942.   '''a scalar. Doing repeated reduction could produce enclosed scalars''       °
  943.  '                                                                             °
  944.   '''that would require removal of such depths before allowing compariso       °
  945.  ns.''' '╕0' 'L22:╕(V>1)/L22X'                                                 °
  946.   '''   RULE 22. The depth of an array is given by the maximum length of       °
  947.  '''                                                                           °
  948.   '''            the access vector associated with that array.'',2µr'          °
  949.   '╕(0=V)/0'                                                                   °
  950.   'L22X:''When you use function DISPLAY, depth can be obtained by counti       °
  951.  ng'''                                                                         °
  952.   '''the number of boxes you must cross from outside to reach the innerm       °
  953.  ost''' '''scalar.''' '╕0' 'L23:╕(V>1)/L23X'                                   °
  954.   '''   RULE 23. Null elements of an access vector must be included to''       °
  955.  ' '''            match corresponding rank zero arrays.'',2µr'                 °
  956.   '╕(0=V)/0'                                                                   °
  957.   'L23X:''The access vector works from left to right. The leftmost eleme       °
  958.  nt'''                                                                         °
  959.   '''removes the outermost box, and the rightmost element removes the'''       °
  960.   '''innermost box.''' '╕0' 'L24:╕(V>1)/L24X'                                  °
  961.   '''   RULE 24. The monadic disclose of a rank 0 array reveals the cont       °
  962.  ents''' '''            of that array.'',2µr' '╕(0=V)/0'                       °
  963.   'L24X:''This is a consequence of rule 21. A simple scalar is immune to       °
  964.  ''' '''to the process of enclosure or disclosure.''' '╕0'                     °
  965.   'L25:╕(V>1)/L25X'                                                            °
  966.   '''   RULE 25. The monadic disclose (without axis specification) reduc       °
  967.  es'''                                                                         °
  968.   '''            depth by one, by adding a new last axis to the disclose       °
  969.  d'''                                                                          °
  970.   '''            elements. FILL elements are used to complete the array.       °
  971.  '',2µr' '╕(0=V)/0'                                                            °
  972.   'L25X:''The fill element for numberic arrays is zero. The fill element       °
  973.   for'''                                                                       °
  974.   '''character arrays is a blank. The fill element for mixed arrays in''       °
  975.  ' '''APL2 will be discussed in later sessions.''' '╕0'                        °
  976.   'L26:╕(V>1)/L26X'                                                            °
  977.   '''   RULE 26. Simple disclose requires that all components of a neste       °
  978.  d'''                                                                          °
  979.   '''            array have the same rank (or be rank 0 arrays).'',2µr'        °
  980.   '╕(0=V)/0'                                                                   °
  981.   'L26X:''We use the phrase ''''simple disclose'''' because, as we will        °
  982.  learn'''                                                                      °
  983.   '''later, you can define your own rules on how to disclose nested'''         °
  984.   '''arrays.''' '╕0' 'L27:╕(V>1)/L27X'                                         °
  985.   '''   RULE 27. Forms can be equivalent only if all rank 0 arrays conta       °
  986.  in'''                                                                         °
  987.   '''            the same rank and shape (or rank 0 arrays)--recursively       °
  988.  --'',2µr' '╕(0=V)/0'                                                          °
  989.   'L27X:''Earlier we discussed functions that are dual. These are one to       °
  990.  '''                                                                           °
  991.   '''one transformations of data. Equivalent forms can be thought of as'       °
  992.  '' '''a kind of dual representation of data structures.''' '╕0'               °
  993.   'L28:╕(V>1)/L28X'                                                            °
  994.   '''   RULE 28. A zero in a partition vector will remove the associated       °
  995.  ''' '''            element.'',2µr' '╕(0=V)/0'                                 °
  996.   'L28X:''The components of a partition vector must be positive integers       °
  997.   or'''                                                                        °
  998.   '''zero. The presence of a zero is treated much the same as in boolean       °
  999.  ''' '''reduction.''' '╕0' 'L29:╕(V>1)/L29X'                                   °
  1000.   '''   RULE 29. Each place in the partition vector, where the value'''        °
  1001.   '''            INCREASES marks a partition.'',2µr' '╕(0=V)/0'                °
  1002.   'L29X:''A partition must ocurr BETWEEN two consecutive elements. These       °
  1003.  ''' '''need not be simple scalars'',r'                                        °
  1004. X 'show ''DISPLAY (1 1 2 2)Γ(1 2) ''''AB'''' (3 4) ''''C''''''' '╕0'           °
  1005. *(1997 7 13 12 28 57 536)                                                      °
  1006.  Fshow ÉFX '╢V show ╢W;╢T;╢B' 'Σ Display and execute ╢W'                       °
  1007.   '╢T╜(0=ÉNC ''╢V'')doif ''╢V╜0'''                                             °
  1008.   '╕((0=╧╢W)doif ''show ╢W,'''' '''''')/0'                                     °
  1009.   '╕((1<╧╢W)doif ''╢V show ■╢W'')/0' '''      '',╢W'                           °
  1010. X '╕((╢V^'':''ε╢W)doif ''╢T╜evaldd ╢W'')/L0' '''ÉEM'' ÉEA ╢W' 'L0:do'          °
  1011. *(1997 8 8 13 11 39 384)                                                       °
  1012.  Fshowdd ÉFX 'u╜showdd w;a;b;c;r'                                              °
  1013.   'Σ Display a direct definition function'                                     °
  1014.   '╕((1=╧w)doif ''u╜showdd Γw'')/u╜0'                                          °
  1015.   '╕((3⌠ÉNC╞w)doif ''(ε╞w),'''' is not a function'''''')/0'                    °
  1016.   'c╜Γ[2]ÉCR╞w' 'c╜notb(2╞c),(Γ''aw α∙'')replace■2╟c'                          °
  1017.   '╕((~''ΣDD''╧3╞2πc)doif ''''''Not a direct definition function'''''')/       °
  1018.  0' 'u╜1' 'b╜('' ''⌠╞c)Γ╞c' 'a╜''      ''' 'r╜2╟3πc'                           °
  1019.   '╕((3=µc)doif ''a,(╞w),'''':'''',r,(3<µ2πc)/''''   Σ'''',3╟2πc'')/0'         °
  1020.   'a╜a,(╞w),'':'',(2╟5πc),'':''' 'b╜(+\r=''('')-+\r='')''' 'b╜b∞0'             °
  1021. X 'a╜a,(²3╟(b-1)╞3╟r),'':'',2╟»(b+1)╟r' 'a,(3<µ2πc)/''  Σ'',3╟2πc'             °
  1022. *(1997 8 8 13 20 30 384)                                                       °
  1023.  Fshowdd╢ ÉFX 'showdd╢;FOO;FOO2' 'Σ Z V Jizba, UTILITY, April 6, 1991'         °
  1024.   '''Function "showdd" is a subroutine in "evaldd". It is invoked'''           °
  1025.   '''whenever the keyboard entry is a label ending with a colon (:).'''        °
  1026.   '''The right argument should be the name of a function that has been''       °
  1027.  '                                                                             °
  1028.   '''fixed using the Direct Definition feature of "evaldd". The function       °
  1029.  '''                                                                           °
  1030.   '''returns a 0 and an appropriate message, if the name is not valid. I       °
  1031.  f'''                                                                          °
  1032.   '''all goes well, the function returns a 1. The boolean value returned       °
  1033.  '''                                                                           °
  1034.   '''by "showdd" is used by function "evaldd" to determine its next acti       °
  1035.  on.'',r' 'show ''showdd ''''FOO'''''''                                        °
  1036.   '''A function that has been defined using "evaldd" contains the sequen       °
  1037.  ce'''                                                                         °
  1038.   '''ΣDD in line 1. If this sequence is absent, "showdd" will also fail'       °
  1039.  ',r' 'show ''showdd ''''showdd'''''''                                         °
  1040.   '''We can use "evaldd" to define function FOO'',r'                           °
  1041.   '1 show ''FOO:∞∙'' ''ÉNC ''''FOO'''''' ''FOO 4'' ''showdd ''''FOO'''''       °
  1042.  ''                                                                            °
  1043.   '1 show ''FOO2:''''no'''':∙:''''yes'''''' ''ÉNC ''''FOO2'''''' ''FOO2        °
  1044.  4<5'' ''showdd ''''FOO2'''''''                                                °
  1045.   '''(The colon is removed by "evaldd".) Normally the right argument is        °
  1046.  a'''                                                                          °
  1047.   '''nested vector since the comment line gets attached first in "evaldd       °
  1048.  ".'',r' 'show ''showdd ''''FOO'''' ''''ΣDD'''''''                             °
  1049.   '''For more information on Direct Definition, try "evaldd╢".'''              °
  1050. X 'endd'                                                                       °
  1051. *(1997 7 13 12 28 57 536)                                                      °
  1052.  Fshowfn ÉFX 'U╜V showfn W;F;N;T;ÉIO' 'Σ Simulate ╖W[É]'                       °
  1053.   'T╜(0=ÉNC ''V'')doif ''V╜0''' 'ÉIO╜0'                                        °
  1054.   'U╜r,''      '',''╖'',W,''[É]'',(╞V)╞''╖''' 'N╜1╞µF╜ÉCR W' 'N╜«∞N'           °
  1055.   'N╜(N⌠'' '')ΓN' 'F╜(π''['',■N,■Γ''] ''),F'                                   °
  1056.   'T╜(1<µ,V)doif ''F╜F[1╟V;]'' ''U╜''''''''''' 'U╜²1╟U,r,,F,r'                 °
  1057. X 'U╜((-+/^\'' ''=ΦU)╟U),('' ╖'')[╞V],r'                                       °
  1058. *(1997 7 28 12 46 20 520)                                                      °
  1059.  Fshowfn╢ ÉFX 'showfn╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                  °
  1060.   '''Function "showfn" is used in documentation to display portions of u       °
  1061.  ser''' '''defined functions'',r'                                              °
  1062.   '''The function is dyadic and returns the desired display'',r'               °
  1063.   'show ''1 showfn ''''showfn'''''''                                           °
  1064.   '''The right argument is the name of the defined function or operator.       °
  1065.  '''                                                                           °
  1066.   '''The left argument is optional, and if absent it is set to zero.'''        °
  1067.   '''If the left argument is a vector, the numbers past the first'''           °
  1068.   '''(boolean) value specify the lines of code to display'',r'                 °
  1069.   'show ''0 1 11 showfn ''''showfn'''''''                                      °
  1070.   '''If the left argument begins with zero, the trailing ╖ is ommited,''       °
  1071.  '                                                                             °
  1072.   '''making it possible to display new lines of code not present in the'       °
  1073.  '' '''function'',r'                                                           °
  1074.   'show ''(0 1 showfn ''''showfn''''),''''[1.1] Σ Insert a new line here       °
  1075.  '''''''                                                                       °
  1076.   '''To display the header, it may be desirable to remove the leading'''       °
  1077.   '''[0]. (note that the result of "showfn" is a simple character vector       °
  1078. X)'',r' 'show ''²31╞4╟0 0 showfn ''''showfn''''''' 'endd'                      °
  1079. *(1997 7 27 14 9 5 316)                                                        °
  1080.  Fshow╢ ÉFX 'show╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991'                  °
  1081.   '''Function "show" is used in documentation to simulate the entry of''       °
  1082.  ' '''an APL2 expression at the terminal.'',r'                                 °
  1083.   '''The function is ambivalent and has no result. The right argument'''       °
  1084.   '''is the expression to be evaluated. It must be a character string.''       °
  1085.  '                                                                             °
  1086.   '''The right argument can also be a nested vector. If it is, "show" wi       °
  1087.  ll'''                                                                         °
  1088.   '''be applied to each component separately. If the left argument is'''       °
  1089.   '''absent, the default is zero. A one in the left argument allows the'       °
  1090.  ''                                                                            °
  1091.   '''evaluation of DIRECT DEFINITIONS. Invalid APL2 expressions will'''        °
  1092.   '''return the appropriate error message.''' 'do'                             °
  1093.   '''EXAMPLES (press Enter TWICE to continue):'',r'                            °
  1094.   'show ''show ''''∞5'''''' ''show ''''?100'''' ''''∞4'''''''                  °
  1095.   '''To display a direct definition, a 1 must be placed in the left argu       °
  1096.  ment'',r'                                                                     °
  1097.   'show ''1 show ''''FOO:∞∙'''''' ''show ''''FOO 4'''''' ''1 show ''''FO       °
  1098.  O:''''''' 'showfn ''show'''                                                   °
  1099.   '''Line [2] sets V╢ to 0 if function "show" is used monadically. In'''       °
  1100.   '''line [3], if the right argument is of depth 0, catenate a blank'''        °
  1101.   '''to W╢ and re-enter "show". In line [4] if the right argument is'''        °
  1102.   '''nested, apply "show" to each component of W╢. In line [5] display''       °
  1103.  '                                                                             °
  1104.   '''the expression to be evaluated. In line [6] test for a colon, and i       °
  1105.  f'''                                                                          °
  1106.   '''present AND the left argument is 1, apply function "evaldd" to W╢.'       °
  1107.  ''                                                                            °
  1108.   '''Then go to line [8]. On line [7] evaluate the expression W╢ with th       °
  1109.  e'''                                                                          °
  1110.   '''Execute alternate command. Line [8] is a pause allowing user to'''        °
  1111. X '''enter additional expressions.''' 'endd'                                   °
  1112. *(1996 4 6 15 59 49 596)                                                       °
  1113.  Fsimdd ÉFX 'u╜simdd w;e' 'Σ Direct definition mode' 'u╜0'                     °
  1114.   '╕((0⌠ÉNC╞w)doif ''''''Already defined'''''')/0' 'e╜''α''ε2πw'               °
  1115.   'w[2]╜Γ''u╜'',''α∙ aw'' replace 2πw' 'w╜w[1 3 2]'                            °
  1116. X 'w[1]╜Γε''u╜'',(e/''a ''),w[1],'' w''' 'u╜╧ÉFX w'                            °
  1117. *(1997 7 28 12 49 32 580)                                                      °
  1118.  Fsimdd╢ ÉFX 'simdd╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991'                °
  1119.   '''Function "simdd" is a subroutine of "evaldd". It completes the'''         °
  1120.   '''process of fixing definition of a SIMPLE DIRECT DEFINITION. This'''       °
  1121.   '''is one where the function label is followed by a single APL2'''           °
  1122.   '''expression'',r'                                                           °
  1123.   'show ''simdd ''''FOO'''' ''''∞∙'''' ''''ΣDD Simple DD'''''''                °
  1124.   '''The left argument to "simdd" is a nested vector with three componen       °
  1125.  ts:'''                                                                        °
  1126.   '''The function name, the APL2 expression and a comment line'',r'            °
  1127.   'show ''ÉNC ''''FOO'''''' ''FOO 4''' '1 show ''FOO:'''                       °
  1128.   '''For more information on Direct Definition, try "evaldd╢".'''              °
  1129. X 'endd'                                                                       °
  1130. *(1992 6 3 9 59 17 424)                                                        °
  1131.  Ftab ÉFX 'U╜V tab W;T;A;B;C;D;E;F;G;M;ÉPW' 'Σ Tabulate list W'                °
  1132.   'T╜(0=ÉNC ''V'')doif ''V╜0''' 'M╜''Invalid data for tabulation'''            °
  1133.   'V╜4╞V' 'ÉPW╜130╛30⌐G╜V[2]+79⌡V[2]=0'                                        °
  1134.   'L1:╕((1<╧W)doif ''''''W╜∞0'''' ÉEA ''''W╜πW'''''')/L1'                      °
  1135.   '╕(((0=µεW)δ2<µµW)doif ''U╜(~V╧4╞0)/M'')/0'                                  °
  1136.   'T╜(1≥µµU╜«W)doif ''U╜πW╜(U⌠'''' '''')ΓU'''                                  °
  1137.   'T╜(0<V[1])doif ''U╜(«(Φ1,╞µW)µ(V[3]µ'''' ''''),∞(╞µW)-V[3]),'''' ''''       °
  1138.  ,U''' '╕(G<30)/0' 'T╜(F╜µεV[4])+C╜1╟B╜µA╜(V[3],0)╟U'                          °
  1139.   'T╜⌐(1╞B)÷1⌐╛(ÉPW+F)÷T' 'U╜(E╜(V[3],C)╞U),[1](B╜T,1╟B)╞A'                    °
  1140.   '''D╜εV[4]'' ÉEA ''D╜ÉAV[εV[4]+33⌡V[4]=0]''' 'L0:A╜(T,0)╟A'                  °
  1141. X '╕(0=1╞µA)/0' 'U╜U,(((T+V[3]),µD)µD),E,[1]B╞A' '╕L0'                         °
  1142. *(1997 7 31 12 54 12 532)                                                      °
  1143.  Ftab╢ ÉFX 'tab╢' 'Σ Copyright Z V Jizba, 1992'                                °
  1144.   '''When an APL2 variable contains a large amount of data, the default'       °
  1145.  ''                                                                            °
  1146.   '''display may cause the screen to roll. Often this data overflow on t       °
  1147.  he'''                                                                         °
  1148.   '''screen can be avoided by re-arranging the data into more than one''       °
  1149.  '                                                                             °
  1150.   '''column. Function "tab" is a utility to do just such folding into tw       °
  1151.  o''' '''or more columns.'',r'                                                 °
  1152.   '''The function is dyadic, and returns the data as a character table.        °
  1153.  The'''                                                                        °
  1154.   '''right argument contains the data to be tabulated. The data can be''       °
  1155.  '                                                                             °
  1156.   '''numeric, character or mixed. It can be a vector, a nested vector,''       °
  1157.  '                                                                             °
  1158.   '''an array or a nested array. The optional left argument specifies th       °
  1159.  e'''                                                                          °
  1160.   '''processing parameters. When missing, "tab" takes all defaults.'',r'       °
  1161.   'do' '''The contents of the left argument V'',r'                             °
  1162.   '''V[1]  0=tabulate data as is (default); 1=add sequence numbers'''          °
  1163.   '''V[2]  Page width (default is 79)'''                                       °
  1164.   '''V[3]  Number of rows to be replicated as header (default is 0)'''         °
  1165.   '''V[4]  Characters to be used between columns. V[4] may be numeric'''       °
  1166.   '''      (elements of ÉAV) or character. Default is a blank.'',r'            °
  1167.   'do' '''Here are examples of the usage of function "tab"'',r'                °
  1168.   ''' 1. Tabulation of numeric vectors'',r' 'show ''tab ∞50'''                 °
  1169.   ''' 2. Tabulation of character vectors'',r'                                  °
  1170.   'show ''tab ''''The government has the power to impose taxes.'''''''         °
  1171.   ''' 3. Tabulation of nested numeric vectors. Note single space separat       °
  1172.  ion''' '''   between consecutive vectors'',r' 'show ''tab 3,/∞50'''           °
  1173.   ''' 4. Tabulation of nested character vectors'',r'                           °
  1174.   'show ''tab 20µ''''one'''' ''''two'''' ''''three'''' ''''four'''' ''''       °
  1175.  five'''' ''''six''''''' ''' 5. Tabulation of numeric arrays'',r'              °
  1176.   'show ''tab 9 3µ3⌡/∞29''' ''' 6. Tabulation of character arrays'',r'         °
  1177.   'show ''tab π20µ''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FOUR'''' '''       °
  1178.  'FIVE'''' ''''SIX'''''''                                                      °
  1179.   '''With a left argument, additional options are possible'',r'                °
  1180.   ''' 7. Numbering individual row entries in a list or table'',r'              °
  1181.   'show ''1 tab ''''The government has the power to impose taxes.'''''''       °
  1182.   'show ''1 tab π20µ''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FOUR'''' '       °
  1183.  '''FIVE'''' ''''SIX'''''''                                                    °
  1184.   ''' 8. Specifying the width of the table. (Minimum page width is 30)''       °
  1185.  ,r'                                                                           °
  1186.   'show ''0 30 tab ''''The government has the power to impose taxes.''''       °
  1187.  '''                                                                           °
  1188.   'show ''1 30 tab ''''The government has the power to impose taxes.''''       °
  1189.  ''' ''' 9. Specifying the number of lines in the header'',r'                  °
  1190.   'show ''0 40 2 tab ''''HEAD'''' ''''²²²²'''',20µ''''ONE'''' ''''TWO'''       °
  1191.  ' ''''THREE'''''''                                                            °
  1192.   '''10. Specifying the character(s) to separate columns'',r'                  °
  1193.   'show ''1 0 0 125 tab ''''The government has the power to impose taxes       °
  1194.  .'''''''                                                                      °
  1195.   '''Multiple characters as separators can be defined several ways'',r'        °
  1196.   'show ''0 0 0 (33 125 33) tab 20µ''''ONE'''' ''''TWO'''' ''''THREE''''       °
  1197.   ''''FOUR'''''''                                                              °
  1198.   'show ''0 0 0 (0 125 0) tab 20µ''''ONE'''' ''''TWO'''' ''''THREE'''' '       °
  1199.  '''FOUR'''''''                                                                °
  1200.   'show ''0 0 0 '''' | '''' tab 20µ''''ONE'''' ''''TWO'''' ''''THREE''''       °
  1201.   ''''FOUR'''''''                                                              °
  1202.   '''If the array to be tabulated is empty, a message appears. However,'       °
  1203.  ''                                                                            °
  1204.   '''if the left argument has all defaults, there will be no message'',r       °
  1205.  ' 'show ''tab ∞0'' ''1 tab ∞0'''                                              °
  1206.   '''The algorithm is simple and straight forward'',r'                         °
  1207.   '0 0 1 2 4 5 showfn ''tab'''                                                 °
  1208.   'r,''Lines [2] and [4] establish the defaults on the left argument. Li       °
  1209.  ne'''                                                                         °
  1210.   '''[5] insures that the minimum and maximum page widths allowed by APL       °
  1211.  2''' '''are not violated.'',r' 'do' '0 3 6 7 showfn ''tab'''                  °
  1212.   'r,''Lines [6] and [7] insure that the right argument is not nested an       °
  1213.  d'''                                                                          °
  1214.   '''does not have a rank greater than 2. Line [3] assigns the empty arr       °
  1215.  ay'''                                                                         °
  1216.   '''message. If the array is empty, and if the left argument does not h       °
  1217.  ave'''                                                                        °
  1218.   '''four zeros, the message M will be displayed on exit from line [7].'       °
  1219.  ',r' 'show ''tab (2 2µ∞4) (3 4) 5'' ''1 tab 2 3 4µ∞24'''                      °
  1220.   '0 8 showfn ''tab'''                                                         °
  1221.   'r,''Line [8] converts simple vectors to arrays'',r'                         °
  1222.   '0 9 showfn ''tab'''                                                         °
  1223.   'r,''Line [9] inserts line numbers in front of table'',r' 'do'               °
  1224.   '0 10 showfn ''tab'''                                                        °
  1225.   'r,''If the given width is less than 30, a single column is returned.'       °
  1226.  ',r'                                                                          °
  1227.   'show ''1 29 tab ''''The government has the power to impose taxes.''''       °
  1228.  ''' '0 10 11 12 showfn ''tab'''                                               °
  1229.   'r,''Lines [11] and [12] find the number of columns of the table'',r'        °
  1230.   '0 13 14 showfn ''tab'''                                                     °
  1231.   'r,''Line [13] formats the first column and captures the header, if an       °
  1232.  y.'''                                                                         °
  1233.   '''Line [14] determines the nature of the column separation characters       °
  1234.  .'',r' 'do' '0 15 16 17 18 showfn ''tab'''                                    °
  1235.   'r,''Lines [15-18] build up the rest of the table.''' 'do'                   °
  1236.   '''PROBLEMS'',r'                                                             °
  1237.   '''The following situations fail to provide a satisfactory result'',r'       °
  1238.   '''1. Entering invalid numeric values in V[4] may cause table overflow       °
  1239.  .'',r'                                                                        °
  1240.   'show ''1 0 0 123.5 tab 8µ''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FO       °
  1241.  UR''''''' '''2. Mixed vectors do not produce clean tables'''                  °
  1242.   'show ''tab ''''TITLE'''' 2 3 4 5 6'''                                       °
  1243.   'show ''1 50 2 '''' | '''' tab ''''TOP'''' ''''²²²'''',?10µ100'''            °
  1244. X 'endd'                                                                       °
  1245. *(1997 7 13 12 28 59 544)                                                      °
  1246.  Ftest ÉFX 'U╜V test W;P'                                                      °
  1247.   'Σ Describe problem in W, (correct answer in V)' 'U╜2' 'L1:W'                °
  1248.   'É╜''      ''' 'P╜æ' '''╕L0'' ÉEA ''P╜»P''' '╕(V╧P)/0'                       °
  1249. X 'L0:╕(0=U╜U-1)/0' '''Incorrect. Try again''' '╕L1'                           °
  1250. *(1997 7 28 12 52 31 588)                                                      °
  1251.  Ftest╢ ÉFX 'test╢' 'Σ Z V Jizba, UTILITY, April 6, 1991'                      °
  1252.   '''Function "teset" is a prototype (eventually more features should be       °
  1253.  '''                                                                           °
  1254.   '''added) to be used in teaching APL2. The right argument describes'''       °
  1255.   '''an APL2 problem to be solved by the student. The left argument'''         °
  1256.   '''contains the correct response. An APL2 prompt waits for a keyboard'       °
  1257.  ''                                                                            °
  1258.   '''entry, and if this evaluates to the correct result, the function'''       °
  1259.   '''returns a 2. If on the first attempt the evaluation fails, the'''         °
  1260.   '''student gets a second chance, but then the score is a 1. After two'       °
  1261.  '' '''failures, the score is 0.''' 'do'                                       °
  1262.   '''In the following examples first try the correct response (∞5). Then       °
  1263.  ''' '''in the second example try an incorrect expression first.'',r'          °
  1264.   'show ''(∞5) test ''''Generate the vector: 1 2 3 4 5'''''''                  °
  1265. X 'show ''(∞5) test ''''Generate the vector: 1 2 3 4 5''''''' 'endd'           °
  1266. XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ                                           °
  1267. *(1997 7 13 12 28 59 544)                                                      °
  1268.  Fvec ÉFX 'U╜vec' 'Σ Draw 2d vector in plane'                                  °
  1269.   'U╜r,r,''2-        +'',r '':      °'',r,''1-    °'',r'                       °
  1270. X 'U╜U,'' :  °'',r,''0|....|....|'',r,'' 0    1    2'',r'                      °
  1271.