home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
teach.zip
/
UTILITY.ATF
< prev
Wrap
Text File
|
1997-08-15
|
104KB
|
1,271 lines
XNÉIO 0 1 °
XNÉCT 0 1.000000000000001E²13 °
XCÉFC 1 6 .,*?_- °
XNÉRL 0 577258720 °
XCÉPR 0 °
XCÉLX 1 2 lx °
*(1996 4 6 16 8 39 356) °
FBIND ÉFX 'BIND' 'Σ Binding rules of APL2' °
''' 1. Brackets bind to the left''' °
''' 2. Left arrow binds to the left''' °
''' 3. Dyadic operator binds to the right''' °
''' 4. Strand notation binding''' °
''' 5. Operator binds to its left''' °
''' 6. Function binds to its left''' °
''' 7. Function binds to its right''' °
X ''' 8. Left arrow binds to its right'',r' °
*(1997 7 13 12 28 47 496) °
FDISPLAY ÉFX 'D╜S DISPLAY A;ÉIO;R;C;HL;HC;HT;HB;VL;VB;V;W;N;B' °
'Σ DISPLAY A GENERAL ARRAY IN PICTORIAL FORM' °
'Σ NORMAL CALL IS MONADIC. DYADIC CALL USED ONLY IN' °
'Σ RECURSION TO SPECIFY DISPLAY RANK, SHAPE, AND DEPTH.' 'ÉIO╜0' °
'»(0=ÉNC ''S'')/''S╜µA''' 'R╜╞µ,S Σ PSEUDO RANK.' °
'C╜''┐┌└┘'' Σ UR, UL, LL, AND LR CORNERS.' °
'HL╜''─'' Σ HORIZONTAL LINE.' °
'HC╜HL,''Θ╕'',HL,''~+ε'' Σ HORIZONTAL BORDERS.' °
'HT╜HC[(0<R)⌡1+0<╞²1╞,S]' 'ΣW╜,0╧■╞0µΓ(1⌐µA)╞A' °
'HB╜HC[3+3╛(''2⌡~A╧«A'' ÉEA ''1+╞ε0⌡(1⌐⌡/µA)╞,A'')+3⌡1<µµS]' °
'VL╜''│'' Σ VERTICAL LINE.' °
'VB╜VL,''Φ╟'' Σ VERTICAL BORDER.' °
'V╜VB[(1<R)⌡1+0<²1╞²1╟,S]' °
'»(0εµA)/''A╜(1⌐µA)µΓ╞A'' Σ SHOW PROTOTYPE OF EMPTIES.' °
'╕(1<╧A)/GEN' '╕(2<µµA)/D3' °
'D╜«A Σ SIMPLE ARRAYS.' 'W╜1╞µD╜(²2╞1 1,µD)µD' °
'N╜²1+1╟µD' '╕(0=µµA)/SS' °
'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[ °
3]' '╕0' 'SS:HB╜((0 '' '')=╞0µΓA)/'' -''' °
'D╜'' '',('' '',[0]D,[0]HB,Nµ'' ''),'' ''' '╕0' °
'GEN:D╜«DISPLAY■A Σ ENCLOSED ...' 'N╜Dδ.⌠'' ''' °
'D╜(Nδ~1ΦN)≡D' 'D╜(δ≡~'' ''╤D)/D' 'D╜((1,µS)µS)DISPLAY D' °
'╕(2≥µ,S)╟D3E,0' 'D3:D╜0 ²1╟0 1╟«ΓA Σ MULT-DIMENSIONAL ...' °
'W╜1╞µD' 'N╜²1+1╟µD' °
'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[ °
3]' 'D3E:N╜²2+µ,S' °
X 'V╜C[Nµ1],[0]VB[1+0<²2╟,S],[0](((²3+╞µD),N)µVL),[0]C[Nµ2]' 'D╜V,D' °
*(1997 7 28 13 40 53 632) °
FEXIT ÉFX 'EXIT' 'Σ Exit from function' °
'''To log off type:'',r,'' )OFF'',r' °
'''You can also log off by clicking on the LOG pull down menu and''' °
'''selecting QUIT. (This process may cause a CONTINUE workspace to be' °
X'' '''saved.)''' '╕' °
*(1997 7 28 13 37 49 604) °
FEXIT╢ ÉFX 'EXIT╢' 'Σ Z V Jizba, July 28, 1997' °
'''Function EXIT tells the student how to log off, and clears the''' °
X '''state indicator.''' 'endd' °
*(1997 7 13 12 28 48 500) °
FGO ÉFX 'GO;T;E;B' 'Σ Expression driver' 'L0:B╜E╜''''' 'æ╜'' ''' °
'T╜æ' '╕(^/'' ''=T)/L0' '╕((^/'')OFF ''=5╞6╟T)doif ''EXIT'')/0' °
'╕(('':''εT)doif ''B╜evaldd (+/^\'''' ''''=T)╟T'')/L0' °
'''E╜ÉEM'' ÉEA T' '╕(0=µ,E)/L0' '╕B/L0' °
'''This is not a valid APL2 expression''' 'æ╜''*''' °
X '╕(''?''⌠╞1╟æ)/L0' 'E' '╕L0' °
*(1997 7 28 13 43 20 512) °
FHELP ÉFX 'HELP;N;I;T' 'Σ Help to student' '''WHAT TO DO'',r' °
''' ° To get out of the lesson''' ''' ENTER: EXIT''' °
''' ° To log off APL2''' °
''' FIRST, ENTER: EXIT THEN ENTER: )OFF''' °
''' ° To get help''' ''' ENTER: HELP''' °
''' ° When you see a prompt''' °
''' ENTER AN APL2 EXPRESSION - OR JUST PRESS: ENTER''' 'do' °
''' ° If you get this line'',r' °
'''This is not a valid APL2 expression'',r,''*'',r' °
''' YOU CAN EITHER''' ''' A. PRESS: ENTER''' °
''' B. PRESS: ? and then ENTER to see what was incorrect''' °
''' in your expression causing that response'',r' 'do' °
'Σ''HINTS'',r' °
'Σ''This lesson is made up of '',(«N╜6),'' components named TEACH*A, w °
here''' 'Σ''the * stands for one or two digit in the range 1-22:'',r' °
'ΣI╜0' 'ΣL0:T╜''TEACH'',(«I╜I+1)' 'ΣT,'' '',1╟(ÉCR T)[2;]' °
'Σ╕(N>I)/L0' 'Σdo' °
'Σ''You may review either of these components separately. To do that,' °
'' °
'Σ''first enter EXIT (and RETURN), then enter the name of the lesson.' °
'' 'Σ''component (e.g. TEACH4).'',r' °
'Σ''To re-start the lesson, just enter TEACH'',r' °
'''When the screen fills up, it is a good idea to move the cursor to'' °
' '''the start of a convenient paragraph, and press ENTER'',r' °
'''You may also wish to press PAGE UP to review the previous pages.''' °
'do' '''RESOURCES'',r' °
'''You may also enter ONE of the following words at a time'',r' °
'''BIND To display APL2 binding rules''' °
'''DISPLAY array To display APL2 array structure''' °
'''EXIT To exit from execution (same as ╕)''' °
'''GO To allow usage of direct definitons'',r' °
''' also'',r' °
X '''number TIME expression -- to estimate execution time''' 'endd' °
*(1997 5 31 11 59 20 572) °
FRULE ÉFX 'V RULE W' 'Σ Display rules' '╕(2=ÉNC ''V'')/L0' °
X '2 rule W ╪ ╕0' 'L0:V rule W' °
*(1997 7 13 12 28 49 504) °
FTIME ÉFX 'U╜V TIME W;T' 'Σ Measure execution time of W' °
X 'U╜60 60 1000¥²3╞ÉTS' 'T╜»■VµΓW' 'U╜(,-U-60 60 1000¥²3╞ÉTS)÷V' °
*(1997 7 13 12 28 49 504) °
Faddquote ÉFX 'u╜addquote w' °
'Σ Put quotes around a string, and double existing quotes' °
X 'u╜ÉAV[40],((1+w=ÉAV[40])/w),ÉAV[40]' °
*(1997 7 28 12 52 59 700) °
Faddquote╢ ÉFX 'addquote╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "addquote" is monadic and produces a result. It takes''' °
'''a character string right argument, and returns it with a leading''' °
'''and trailing quote. Any quote(s) in the string will be doubled.'',r °
' °
'show ''''''ONE'''''' ''addquote ''''ONE'''''' '''''''''''''''''''' '' °
addquote ''''''''''''''''''' °
'''When a character string in quotes is evaluated, APL2 returns that'' °
' °
'''string without quotes (first example). Applying addquote to that''' °
'''same string, the quotes are retained (example 2). A single quote''' °
'''is described by four quotes: leading and trailing quotes to define' °
'' °
'''a string, and two quotes to define a quote (example 3). Example 4'' °
X' '''shows addquote returning the string defining a single quote.''' °
*(1997 7 24 13 20 38 476) °
Fav ÉFX 'av;A;N;I;ÉIO' 'Σ Display characters in ÉAV' 'ÉIO╜0' °
'A╜22 78µ'' ''' 'N╜3 0«φ12 22µ1+∞356' 'A[;,(6⌡∞12)°.+2 3 4]╜N' °
'A[;6+6⌡∞12]╜φ12 22µÉAV' 'ΣA[8 10 13;6]╜'' ''' 'A[13;6]╜'' ''' °
X 'A[14+∞8;68 69 70 72]╜'' ''' 'A' °
*(1997 7 28 12 53 9 504) °
Fav╢ ÉFX 'av╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "av" displays the 256 characters in ÉAV, the ATOMIC VECTOR °
''' 'show ''av''' °
'''The symbol for ÉAV[14] represents a line feed. It is made blank to °
avoid''' °
'''a disruption in the table. ÉAV[33] is the blank character.''' °
X 'endd' °
*(1991 11 11 8 25 13 316) °
Fdate ÉFX 'u╜date w' 'Σ Format date and time of day' 'u╜«6╞w' °
X 'u╜('' ''⌠u)Γu' 'u╜εu,■''-- .. ''' °
*(1997 7 31 13 0 3 284) °
Fdate╢ ÉFX 'date╢' 'Σ Copyright Z V Jizba, 1994' °
'''APL2 System Variable ÉTS returns an integer vector specifying the'' °
' °
'''current date and time. When a user defined function is displayed us °
ing''' °
'''the del (╖) symbol, the IBM software supplies a time stamp listing' °
'' °
'''the date and time in a more readable format. The year, month and da °
y''' °
'''are separated by a dash, and the hour, minute and second are separa °
ted''' °
'''by the period. Function "date" converts a numeric vector into this' °
'' °
'''format. It is useful in the simulation of function listing through' °
'' '''function "showfn".'',r' 'show ''ÉTS'' ''date ÉTS''' °
'''The function does not require the right argument to contain any''' °
'''numbers, but if it does not the right argument should be prepared'' °
' '''with some care.'',r' 'show ''date ∞0'' ''date 0 ''''ABC''''''' °
'''THE ALGORITHM'',r' '(0 0 1 2 showfn ''date''),r' °
'''On line [2] only the first 6 elements of the right argument are''' °
'''selected, and are formatted. Note that this line would cause''' °
'''certain arguments containing characters to fail'',r' °
'show ''DISPLAY «6╞0 ''''abc'''' ''''def'''' ''''g'''' ''''h'''' ''''i °
''''''' '''To get around this problem, one can enter'',r' °
'show ''date ,■''''year'''' ''''month'''' ''''day'''' ''''h'''' ''''m' °
''' ''''s''''''' '(0 3 4 showfn ''date''),r' °
'''On line [3] the six numeric values are extracted as nested vectors. °
''' °
'''On line [4] the dashes a blank and periods are inserted, and the''' °
'''result is converted to a simple vector, which is returned by the''' °
X '''function.''' 'endd' °
XCdig 1 10 1234567890 °
*(1997 7 3 12 47 22 432) °
Fdisclaimer ÉFX 'disclaimer' 'Σ Copyright statement' °
'(10µ'' ''),''Copyright, Z. V. Jizba, 1995,1996,1997'',r' °
''' This and subsequent workspaces labelled TEACHxx are made available °
''' °
'''at no cost to anyone who desires to learn how to use effectively''' °
'''the IBM/OS2 version of APL2.'',r' °
'''This software is provided "AS IS" with no WARRANTY of any kind, eit °
her''' °
'''express or implied. Any risk in its use resides with you, the user °
Xof''' '''these tutorials.''' '''(PRESS ENTER to continue)''' °
*(1997 7 26 13 11 27 404) °
Fdisclaimer╢ ÉFX 'disclaimer╢' 'Σ Z V Jizba, July 26, 1997' °
'''Function "disclaimer" displays the copyright notice and informatiom °
''' °
'''about the conditions under which the APL2OS2 tutorials can be used. °
X''' 'endd' °
*(1997 7 13 12 28 50 508) °
Fdo ÉFX 'do;T;E' 'Σ Expression driver' 'E╜''''' 'æ╜'' ''' 'T╜æ' °
'╕(^/'' ''=T)/0' °
'╕(('':''εT)doif ''B╜evaldd (+/^\'''' ''''=T)╟T'')/2' °
'''E╜ÉEM'' ÉEA T' '╕(0=µ,E)/2' °
'''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/2' °
X 'E' '╕2' °
*(1997 7 13 12 28 50 508) °
Fdoif ÉFX 'U╢╜V╢ doif W╢;t╢' 'Σ Rule' '╕(^/~U╢╜V╢)/0' °
X '''U╢╜V╢ doif■ W╢'' ÉEA ''»V╢/W╢''' °
*(1997 7 28 12 53 50 668) °
Fdoif╢ ÉFX 'doif╢;T' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "doif" is a utility to provide conditional evaluation of'' °
' °
'''expressions. The left argument is an expression that must return a' °
'' °
'''boolean value. This could be a scalar or a vector. If it is a vecto °
r,''' °
'''it must have the same length as the left argument, which then must' °
'' °
'''be nested. The right argument is one or more character strings. The °
se''' °
'''should be valid APL2 expressions. The function returns the result o °
f''' '''evaluating the left argument.''' 'do' °
'''If the left argument returns a zero, the function returns zero, and °
''' '''the right argument is ignored'',r' 'show ''0 doif ''''∞5''''''' °
'''If the left argument returns a one, the right argument is evaluated °
'',r' 'show ''1 doif ''''∞5''''''' °
'''If the right argument contains more than one expression, these will °
''' °
'''be evaluated after reduction by the left argument boolean vector'', °
r' 'show ''1 doif ''''T╜3'''' ''''T╜4'''' ''''∞■T''''''' °
'show ''T╜1 0 1 doif ''''T╜3'''' ''''T╜4'''' ''''∞■∞T'''''' ''T''' °
'''Notice that the function returns a vector if the right argument is °
a''' '''vector'',r' °
'show ''DISPLAY 0 1 1 doif ''''T╜3'''' ''''T╜4'''' (''''∞T'''' ''''∞■∞ °
T'''')''' °
'''Function "doif" assigns the result to local header variable U╢. In' °
'' °
'''some applications it may be desirable to return a result from the'' °
' °
'''right argument, rather than the default boolean vector. This can be °
''' '''accomplished by assigning a right hand expression to U╢'',r' °
'show ''T╜1 0 1 doif ''''U╢╜3'''' ''''T╜4'''' ''''∞■∞T'''''' ''T''' °
'''Function "doif" was originally developed for an early version of AP °
L''' °
'''that did not support the "diamond" (╪). User defined functions can' °
'' °
'''now use the diamond to provide some of the functionality of "doif". °
''' °
'''However, there are applications, where expressions may be stored in °
''' °
'''character arrays to be retrieved in a random way. There, the functi °
Xon''' '''"doif" may still be useful.''' 'endd' °
*(1997 7 28 12 54 31 596) °
Fdo╢ ÉFX 'do╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "do" simulates the APL2 prompt. If the keyboard entry is'' °
' '''Enter, or all blanks followed by Enter, the function exits.'',r' °
'show ''0 3 4 5 showfn ''''do''''''' °
'''If a non blank line is entered, and if it contains at least one col °
on,''' °
'''then an attempt is made to evaluate it as a direct definition'',r' °
'show ''0 6 showfn ''''do''''''' °
'''(The leading blanks are removed first. See also documentation''' °
'''of functions doif and evaldd)''' 'do' °
'''Else the line is evaluated as a valid APL2 expression'',r' °
'show ''0 2 7 8 showfn ''''do''''''' °
'''The error message is not displayed at first. Instead, another''' °
'''message merely states that the expression is not valid, and a line' °
'' °
'''with * is made available as a prompt. Any expression on this line'' °
' °
'''other than one beginning with ? returns to the start. The ? causes' °
'' '''the ERROR MESSAGE to be displayed'',r' °
'show ''0 9 10 11 12 showfn ''''do''''''' °
'''To test this function, first enter ÉLC. This will give you the curr °
ent''' '''LINE COUNT. Then enter'',r' ''' do'',r' °
'''and again try ÉNC to show 7 indicating you are evaluating line''' °
'''7 of function do. You can try to evaluate valid and invalid APL2''' °
'''expressions (System commands will be treated as invalid). Also test °
''' °
'''the ERROR MESSAGE by entering ''''?''''. Finally, enter a blank lin °
e to''' °
'''exit ''''do''''. Then enter ÉLC to verify you are out of the functi °
Xon.''' 'endd' °
*(1997 7 25 12 51 38 600) °
XFendd ÉFX 'endd' 'Σ end of special feature' '20µ''²''' 'Σdo' °
*(1997 7 25 12 58 51 680) °
Fendd╢ ÉFX 'endd╢;T' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''This function prints a line of 20 bars (and pauses for user input)' °
'' 'showfn ''endd''' °
'''It is used at the end of documentation functions such as HELP to''' °
'''indicate their completion. (The example below illustrates its usage °
''' °
'''to indicate the end of this documentation.) The pause (function "do °
")''' °
'''is commented out in this workspace. In the tutorials the pause give °
s''' °
'''the student one last chance to try out expressions that may rely on °
''' '''local variables present in the expository function.'',r' °
X 'show ''endd''' °
*(1997 7 24 13 13 50 496) °
Ferase ÉFX 'erase;t;EXIT;GO;HELP;DISPLAY;BIND;REVIEW;RULE;TIME' °
'Σ Erase all global functions and variables' 't╜ÉNL 3' °
't╜(~t^.εlc,'' ╢'')≡t' 't╜ÉEX(~t[;∞5]^.=''TEACH'')≡t' 't╜ÉNL 2' °
X 't╜ÉEX(~t^.εlc,'' ╢'')≡t' 't╜ÉNL 4' 't╜ÉEX(~t^.εlc,'' ╢'')≡t' °
*(1997 7 28 12 58 5 508) °
Ferase╢ ÉFX 'erase╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "erase " will erase all APL2 objects from the workspace th °
at''' °
'''may have been generated during its usage. The function is niladic'' °
' '''and consists of the following steps:'',r' °
''' 1 Remove all functions except those in lower case, those''' °
''' listed in the header, and those named TEACH*. (Here * has''' °
''' the same meaning as in DOS)''' °
''' 2 Remove all variables except those in lower case and any''' °
''' defined in the header.''' °
''' 2 Remove all defined operators except those in lower case and''' °
''' any defined in the header.'',r' °
'show ''Ab╜∞5'' ''ÉFX ''''U╜FOO'''' ''''U╜∞5'''''' ''ÉFX ''''U╜(f OP) °
W'''' ''''U╜∞5''''''' 'show ''ÉNC■''''Ab'''' ''''FOO'''' ''''OP''''''' °
'show ''erase''' 'show ''ÉNC■''''Ab'''' ''''FOO'''' ''''OP''''''' °
'''NOTE: FUNCTION erase IN THIS WORKSPACE ONLY (UTILITY) ALLOWS NAMES' °
X'' ''' TO CONTAIN THE CHARACTER ╢.''' 'endd' °
*(1997 8 4 12 17 23 324) °
Ferrors ÉFX 'errors W;EC;RT;R' 'Σ Display error message' °
'╕((1<╧W)doif ''errors■ W'')/0' ''' '',W' '(EC RT R)╜ÉEC W' 'R' °
X 'do' °
*(1997 8 4 12 16 56 452) °
Ferrors╢ ÉFX 'errors╢;T;E' 'Σ Z V Jizba, UTILITY, August 4, 1997' °
'E╜Γ[2]ÉCR ''errors'' ╪ T╜ÉFX 6╞E' °
'''Function "errors" is used in the tutorials to display error message °
s''' °
'''caused by invalid APL2 expressions. This function uses the Execute' °
'' °
'''Controlled System command to extract the error message, avoiding an °
''' '''interrupt. The function is monadic'',r' °
'show ''errors ''''∞∞''''''' °
'''When the expression "errors ''''∞∞''''" is evaluated (first line), °
the''' °
'''expression "∞∞" is displayed first (second line). This is followed' °
'' '''by the error message (last three lines).'',r' °
'show ''errors ''''∞5''''''' °
'''When the right argument to the "errors" function is a valid express °
ion,''' °
'''the result of that expression is displayed instead of an error mess °
Xage.''' 'T╜ÉFX E' 'showfn ''errors''' 'endd' °
*(1996 4 6 15 59 49 596) °
Fevaldd ÉFX 'u╜evaldd w;c;n' 'Σ Evaluate direct definition' 'u╜0' °
'n╜(w∞''Σ'')-1' 'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w' °
'╕(label╞c)/0' '╕((2=µc)doif ''u╜showdd 1╙c'')/0' °
'╕((3=ÉNC╞c)doif ''u╜⌡µÉ╜(╞c),'''' is already defined.'''''')/0' °
'╕((3=µc)doif ''u╜simdd c'')/0' 'c╜(Γ''α∙ aw'')replace■c' °
'u╜ε''u╜'',((''a''εεc[2 3 4])/''a ''),(╞c),'' w;t;b''' °
'u╜u(5πc)(''b╜(t╜'',(3πc),'')/'',addquote ''u╜'',4πc)' °
X 'u╜u,''╕(t doif b)/0''(''u╜'',2πc)' 'u╜╧ÉFX u' °
*(1997 7 28 13 4 52 484) °
Fevaldd╢ ÉFX 'evaldd╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "evaldd" is normally used as a subroutine of function "do" °
.''' °
'''It is invoked whenever the string entered at the terminal contains' °
'' °
'''a colon. The presence of a colon indicates the likelihood of a DIRE °
CT''' °
'''DEFINITION. Although this mode of function definition is not suppor °
ted''' °
'''by APL2, its usage in the APL literature calls for support in a tut °
orial''' '''on the language.'',r' °
'''Before we describe the nature of function "evaldd" we need to expla °
in''' '''this concept of direct definition.''' 'do' °
''' DIRECT DEFINITION'',r' °
'''In APL2, user defined functions can be constructed using a built in °
''' °
'''EDITOR, or with the help of the FUNCTION DEFINITION MODE. For the'' °
' °
'''later, the character ╖ is a toggle switch between this function''' °
'''definition mode and APL2 execution mode. With direct definition (DD °
),''' °
'''there should be no need for invoking the editor or for switching mo °
des.''' °
'''Functions could be defined in the execution mode. But there is a''' °
'''limitation. The function to be defined must be expressible in ONE l °
ine.''' °
'''Function "evaldd" simulates the availability of direct definition b °
y''' '''supporting its three formats:'',r' °
''' FUNNAME:expression''' °
''' FUNNAME:left-expression:condition:right-expression''' °
''' FUNNAME:'',r' °
'''The first two forms define a DD function. The third one displays''' °
'''a previously defined direct definition. The defined function may be °
''' °
'''monadic or dyadic, and it will always produce a result. The right'' °
' °
'''argument to the function is represented by the symbol ∙, and the''' °
'''left argument by the symbol α.''' 'do' °
'''In the first form (FUNNAME:expression), the function returns the''' °
'''result of the expression. In the conditional form, (the second''' °
'''expression) condition is evaluated first. It must return a boolean' °
'' °
'''scalar. If it is a one, then the right-expression will be evaluated °
''' °
'''and returned. If the condition returns a zero, then the left-expres °
sion''' °
'''will be evaluated and returned. Examples are given below.''' 'do' °
''' FUNCTION evaldd'',r' °
'''Normally, "evaldd" is invoked by functions "do" and "go" whenever a °
''' °
'''colon is detected in the string entered at the keyboard. Therefore, °
''' °
'''"evaldd" is monadic. The right argument is the string containing at °
''' °
'''least one colon. The function returns a one if the DD expression ha °
s''' °
'''been successfully completed. It returns a zero if the evaluation fa °
ils.'',r' ''' '',4╟0 0 1 showfn ''evaldd''' °
'''Due to the nature of these APL2 tutorials, there are some extra''' °
'''conditions that the right argument to "evaldd" must satisfy:'',r' °
''' 1. Function to be defined must begin with an upper case letter'' °
' ''' 2. Comments (text following symbol Σ) is allowed''' °
''' 3. New function must not have the same name as that of a''' °
''' previously defined function.'',r' 'do' °
'0 2 3 4 5 showfn ''evaldd''' °
'''Line [2] assigns 0 (fail) to the return variable. Line [3] finds''' °
'''the location of the lamp (Σ) symbol, if it is present. Line [4]''' °
'''first partitions the argument to the left of any Σ symbol'',r' °
''' (((n╞w)⌠'''':'''')Γn╞w)'',r' °
'''Then it catenates the enclose of string "ΣDD", followed by any''' °
'''comments. Line [5] uses utility "label" to test for presence''' °
'''of a valid name (Start with an upper case letter). If this test fai °
ls,''' '''"evaldd" exits.''' 'do' '0 6 7 8 showfn ''evaldd''' °
'''If the expression is of the form FUNNAME:, then line [6] calls''' °
'''function "showdd" with FUNNAME as right argument (see showdd╢).''' °
'''If FUNNAME already exists as a function, further processing is''' °
'''aborted on line [7]. If the expression is of the form FUNNAME:exp,' °
'' °
'''then the nested vector c is sent to function "simdd" for final''' °
'''processing (see simdd╢). If neither of these events take place, the °
n''' °
'''the direct definition is of the form FUNNAME:left:condition:right'' °
,r' '0 9 showfn ''evaldd''' °
'''Line [9] replaces all ocurrences of α and ∙ by "a" and "w". This''' °
'''means that these two letters should not be used as symbols in the'' °
' °
'''DD expressions. (See replace╢ for explanation of this utility).''' °
'do' '0 10 showfn ''evaldd''' °
'''Line [10] generates a standard header'',r' °
'0 11 showfn ''evaldd''' °
'''On line [11] the header is followed by the comment line (5πc). Then °
''' '''the right-argument is extracted if condition is true'',r' °
'0 12 showfn ''evaldd''' °
'''If true, evaluate right argument and exit, else evaluate left argum °
ent'',r' '0 13 showfn ''evaldd''' °
'''Finally the nested string generated in lines [10-12] is fixed. If'' °
' °
'''the process works, ╧ÉFX will return a one, else it will return a''' °
'''zero.''' 'do' '''EXAMPLES'',r' °
'show ''evaldd ''''HELP:∞5 Σ A new function''''''' °
'show ''evaldd ''''help:∞5 Σ A new function''''''' °
'show ''evaldd ''''FOO:∞∙ Σ A new function'''''' ''1 showfn ''''FOO'' °
'''' ''FOO 5''' °
'show ''ÉEX ''''FOO'''''' ''evaldd ''''FOO:∞α:α<∙:∞∙ Σ Do the larger °
integer''''''' 'show ''1 showfn ''''FOO'''''' ''4 FOO 6'' ''5 FOO 2''' °
X 'endd' °
*(1997 7 25 13 27 52 564) °
Fexit ÉFX 'V exit W;T' 'Σ Exit if too many suspended functions' °
'╕(0⌠ÉNC ''V'')/L0 ╪ V╜10' 'L0:╕(V>µÉLC)/0' °
'''There are too many suspended functions''' '''Please enter '',W' °
X '╕' °
*(1997 7 28 13 5 3 292) °
Fexit╢ ÉFX 'exit╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Some students may attempt to enter expressions that cause excessive °
ly''' °
'''long vector of suspended functions. For this reason many expository °
''' °
'''"TEACH*" functions invoke "exit" to test for this condition. The ri °
ght''' °
'''argument to "exit" in the tutorials is usually the string ''''TEACH °
..''''''' °
'''In this way, the student is prompted to re-enter the proper APL2''' °
'''expression to continue the tutorial after the line counter is clear °
ed''' '''out.''' 'showfn ''exit''' °
'''The optional left argument allows changing the default maximum leng °
th''' '''(10) of the line counter'',r' °
'show ''ÉFX ''''FOO'''' ''''ÉLC'''' ''''1 exit ''''''''endd''''''''''' °
' ''''do''''''' '1 showfn ''FOO''' °
'''Note that after the message: Please enter: ..., you will no longer' °
'' °
'''be in execution mode [try any System Command such as )SI. It should °
X''' '''work at that point].'',r' 'show ''FOO''' 'endd' °
*(1997 7 26 12 33 39 536) °
Fget ÉFX 'U╜V get W;t;T;ÉPR' 'Σ Prompt for response from keyboard' °
'ÉPR╜T╜ÉAV[ÉIO+255] ╪ ╕(0⌠ÉNC ''V'')/L0 ╪ V╜1' 'L0:V╜V╧1' 'æ╜W ╪ t╜æ' °
'U╜(+/^\t=T)╟t' '╕(''╕''⌠╞U)/L1 ╪ ╕' 'L1:╕V/0' 't╜(U⌠'' '')ΓU' °
X 'U╜(µt),(ΓU),t' °
*(1997 7 28 13 14 2 324) °
Fget╢ ÉFX 'get╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "get" was designed to handle text processing. The objectiv °
e''' °
'''of this function is to display a prompt, and then accept text input °
''' °
'''from the terminal on the same line as the prompt. The right argumen °
t''' °
'''is the prompt. Normally, the function is invoked monadically.''' °
'''A zero left argument, when present, will partition the user entry'' °
' '''into an array of words, and return a nested vector with''' °
''' 1. The number of words in the user entry''' °
''' 2. The original user entry''' °
''' 3.... The partitioned user entry'',r' °
'''You may backspace into the prompt, but it is NOT recommended. If yo °
u''' °
'''backspace into the prompt and then enter text, each time your text' °
'' °
'''character matches the prompt character the space will be filled out °
''' °
'''by the Prompt Replacement symbol. In the following two examples,''' °
'''after backspacing, enter two or three words, and in one of the''' °
'''examples re-enter a word having at least one letter the same as tha °
t''' '''of the underlying prompt'',r' °
'show ''DISPLAY get ''''Backspace, then enter a short phrase: ''''''' °
'show ''DISPLAY 0 get ''''Backspace, then enter a short phrase: '''''' °
' 'showfn ''get''' °
'''On line [2] the last character of the Atomic vector is assigned as °
a''' °
'''prompt replacement. If the left argument is missing, the default is °
''' °
'''set to 1. Line [3] insures that V is a boolean scalar. Line [4]''' °
'''displays the prompt and places user input into local variable "t".' °
'' °
'''Line [5] rejects the initial string of T''''s (ÉAV[256]) from strin °
g "t"''' '''and assigns the result to U.'',r' °
'''In line [6] if the first character in "t" is a branch (╕), escape'' °
' °
'''(i.e. Clear the state indicator). If on line [7] V=1 exit. Else, '' °
' °
'''if V is 0, partition the user entry into words [8] and place into U °
''' °
'''the number of words, the user entry, and the nested vector of words °
X.''' 'endd' °
*(1997 7 28 13 33 8 424) °
Fglobals ÉFX 'globals' 'Σ Initialize useful global variables' °
'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' °
'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890''' °
X 'r╜ÉAV[13+ÉIO]' 'q╜''''''''' °
*(1997 7 28 13 34 33 528) °
Fglobals╢ ÉFX 'globals╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "globals" is normally used by a workspace initializing fun °
ction''' °
'''to establish certain (lower case) variables as global to the''' °
'''workspace. These globals are of the type that may be used by other' °
'' '''APL2 functions'',r' '''GLOBAL CONTENTS''' °
''' q single quote''' °
''' r New line (return character)''' °
''' uc Upper case letters''' ''' lc Lower case letters''' °
X ''' dig Digits'',r' 'show ''uc ╪ lc ╪ r ╪ q,dig,q''' 'endd' °
*(1997 7 3 12 47 6 368) °
Finitialize ÉFX 'initialize;T' 'Σ Initialize workspace' °
'''AT ALL TIMES, TO CONTINUE, PRESS RETURN!'',r' °
'''To see disclaimers enter:'',r,'' disclaimer''' 'do' 'erase' °
'globals' °
'''Make sure the CAP LOCK light on your keyboard (upper right) is ON!' °
X'' 'endd' °
*(1997 7 28 13 17 39 484) °
Finitialize╢ ÉFX 'initialize╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "initialize" is a prototype of a defined function that can °
be''' °
'''used as the latent variable of the workspace. It is niladic and pro °
duces''' °
'''no result, but it resets the environment of the workspace to its''' °
'''start condition. The function does the following:'',r' °
''' 1. Instructs the user on how to proceed''' °
''' 2. Tels how to obtain copyright and warning note''' °
''' 3. All APL2 objects not belonging to the workspace are erased''' °
''' 4. All global variables are re-defined''' °
''' 5. The user is asked to press the CAPS LOCK key.''' °
''' The "Caps Lock" should be set to ON to insure that any''' °
''' assignments made by the student will be in CAPS. (Function''' °
''' "erase" will erase ALL but some selected names in CAPS.'',r' °
'''This function can be used directly (ÉLX╜''''initialize''''), or can °
be''' °
'''incorporated in another defined function or expression to be used a °
Xs''' '''the latent variable.''' 'do' 'showfn ''initialize''' 'endd' °
*(1997 7 27 13 14 33 444) °
Flabel ÉFX 'u╜v label w' °
'Σ Return 1 if label w does not begin with a cap' °
'╕(0⌠ÉNC ''v'')/L0 ╪ v╜0' 'L0:v╜v╧1 ╪ w╜εw ╪ ╕v/L1 ╪ ╕(u╜0⌠ÉNC w)/0' °
X 'L1:╕(u╜~^/wεlc,uc,dig)/0' 'u╜w[1]εlc,dig' °
*(1997 7 28 13 18 45 512) °
Flabel╢ ÉFX 'label╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "label" is ambivalent. It returns a boolean value. The rig °
ht''' °
'''argument is presumed to be a rank-0 depth-1 character vector. If''' °
'''it is a valid APL2 label, is not already defined in the workspace,' °
'' °
'''and does not begin with a lower case letter, the function will''' °
'''return a zero. Else, the function will return a 1.'',r' °
'show ''label ''''TEST'''' ╪ label ''''tEST23'''' ╪ label ''''3test''' °
'''' °
'show ''label ''''TEST_TWO'''' ╪ label ''''DISPLAY'''' ╪ label ''''tes °
t''''''' °
'''In the examples above only the first one is acceptable.'',r' °
'''If a left argument is given, it should be a 1. When present, it cau °
ses''' '''the test for Name Class to be omitted.'',r' °
'show ''1 label ''''DISPLAY''''''' °
'''This function is used in some tutorials to insure that the student °
will''' °
'''name APL2 objects in a manner that will avoid conflicts. Furthermor °
e,''' °
'''it insures that these labels will be erased by utility function "er °
ase".''' 'showfn ''label''' °
'''Line [2] assigns a zero to "v" if the left argument is absent. Line °
''' °
'''[3] insures the left argument to be boolean, and the right argument °
''' °
'''to be enlisted. If v=1, the Name Class test is omitted. Line [4]''' °
'''rejects the label if it contains special characters, and line [5]'' °
' °
'''rejects the label if the first character is a digit or lower case'' °
X' '''letter.''' 'endd' °
XClc 1 26 abcdefghijklmnopqrstuvwxyz °
*(1997 8 15 12 37 24 452) °
Flx ÉFX 'lx' 'Σ Latent variable for UTILITY workspace' °
'''Functions in lower case are utility functions. Some of these''' °
'''utilities are described in the tutorials. Functions in upper case'' °
' °
'''are considered to contain tutorial text. (Exception:DISPLAY is an'' °
' '''IBM copyrighted utility.)'',r' °
'''To find out what functions are available, enter'',r,'' )FNS'', °
r' °
'''To find out what variables are available, enter'',r,'' )VARS'' °
,r' °
'''There are no defined operator utilities in this workspace. Any''' °
'''function name ending with ╢ is a documentation function. Entering'' °
' °
'''this label (including ╢) will describe that function. Variables in' °
'' °
'''lower case may be displayed direcly. These are self explanatory, bu °
t''' '''you may also enter: globals╢.'',r' °
'''Lower case functions not described here, should not be considered'' °
' '''as part of the utility set.'',r' °
'''The first 8 tutorial workspaces summarize the APL2 grammar and''' °
'''syntax by listing a set of rules. These rules can be accessed in''' °
'''this utility workspace by entering:'',r' ''' 1 RULE n'',r' °
'''where n is the rule number (from 1 to 35). The remaining workspaces °
''' °
'''(TEACH9 through TEACH22) deal with the APL2 syntax in a different w °
ay.''' °
'''There is a set of "binding rules" that fully defines the APL2 synta °
x.''' '''To get a listing of these binding rules, enter'',r' °
X ''' BIND'',r' 'endd' °
*(1997 7 13 12 28 55 528) °
Fnon ÉFX 'non;T;RC;ET;R' 'Σ Ignore keyboard entry' 'æ╜'' ''' 'T╜æ' °
'╕(0=µ(T⌠'' '')/T)/0' '(RC ET R)╜ÉEC T' '╕(0=RC)/2' °
X '╕((1=RC)doif ''R'')/2' '╕2' °
*(1997 7 27 12 49 55 668) °
Fnon╢ ÉFX 'non╢;TEST' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "non" is used in tutorials at places where invalid APL2''' °
'''expressions are to be ignored. Valid APL2 expressions, however,''' °
'''are evaluated normally'',r' °
'''In the following invocation of "non", first enter ∞5, then try''' °
'''TEST╜∞5. Then enter some nonsense text, and then just press Enter'' °
' '''(twice!) to exit this documentation.'',r' 'show ''non''' °
'showfn ''non''' °
'''The function is similar to function "do". When an error is detected °
X,''' '''unlike "do" it just ignores that expression.''' 'endd' °
*(1997 7 13 12 28 55 528) °
Fnotb ÉFX 'u╜notb w' 'Σ Remove trailing blanks' °
'╕((1<╧w)doif ''u╜notb■ w'')/0' '╕((1<µµw)doif ''u╜πnotb Γ[2]w'')/0' °
X 'u╜(1-(,'' ''⌠Φw)∞1)╟w' °
*(1997 7 27 12 52 23 552) °
Fnotb╢ ÉFX 'notb╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "notb" is monadic, and produces a result'',r' °
'²24╞4╟0 0 showfn ''notb''' °
'''The right argument is presumed to be a vector, a nested vector or'' °
' °
'''a character array of rank 2. The result is an object of the same''' °
'''shape, rank and depth but with excess trailing blanks removed.''' °
'do' '''EXAMPLES:'',r' 'show ''DISPLAY notb ''''ONE TWO ''''''' °
'show ''DISPLAY notb ''''ONE '''' ''''TWO '''' '''' ''''''' °
'show ''DISPLAY notb (2 4µ''''ONE TWO ''''),2 5µ'''' ''''''' °
X 'showfn ''notb''' 'endd' °
*(1997 7 27 12 55 6 496) °
Fproblems ÉFX 'problems' 'Σ Problems' °
'''That is all for this lesson. Remember, if you want to practice,''' °
'''and plan to use direct definitions, be sure to first enter GO.''' °
'''Direct definitions will then be accepted. To exit GO, enter EXIT.'' °
,r' °
'''To erase a previously defined DIRECT DEFINITION FUNCTION, enter'',r °
' ''' )ERASE functionname'',r' °
X '''WARNING! do not use )ERASE on other labels.'',r' °
*(1997 7 28 13 27 6 392) °
Fproblems╢ ÉFX 'problems╢' 'Σ Z V Jizba, July 28, 1998' °
'''This utility is used to indicate the end of a tutorial lesson.''' °
'''Should the student try to save the workspace, it gives instruction' °
'' °
'''on how to erase any APL2 objects generated by the student should''' °
'''the student choose to do so. (On loading the workspace, function''' °
'''"erase" will do that as well).'',r' °
'''This function will also instruct the student to invoke function''' °
X '''GO if the use of Direct Definitions is desired.''' 'endd' °
XCq 0 ' °
XCr 0 °
*(1997 7 13 12 28 56 532) °
Freplace ÉFX 'u╜v replace u;i;r;s' 'Σ Replace elements in v in u' °
'i╜Γ∞µu' 's╜2πv╜(v⌠'' '')Γv' 'i╜⌡r╜i⌡■Γ[1]u°.=╞v' °
X 'u[(εi)/εr]╜s[(εi)/εi⌡■∞µs]' °
*(1997 7 27 12 56 29 592) °
Freplace╢ ÉFX 'replace╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "replace" is used to replace selected characters in the ri °
ght''' °
'''argument. The characters to be replaced, and their replacements are °
''' °
'''specified in the left argument. The two parts are separated by a''' °
'''blank'',r' '²24╞4╟0 0 showfn ''replace''' °
'''Note that the right argument label is the same as that of the resul °
t.''' '''The right argument should be a character vector'',r' °
'0 2 showfn ''replace''' °
'''First, a scalar is generated containing the numeric count of the''' °
'''components of the right argument''' 'do' '0 3 showfn ''replace''' °
'''Next, the elements of the left argument are extracted (locals s and °
v)''' 'do' '0 4 showfn ''replace''' °
'''The position and identity of the symbols to be replaced are stored °
in''' '''variables i and r''' 'do' '0 5 showfn ''replace''' °
'''Finally the replacements are made'',r' '''EXAMPLES:'',r' °
'show ''''''OT AB'''' replace ''''ONE TWO THREE''''''' °
'''The function was designed to be used in the replacement of α and ∙' °
'' '''in DIRECT DEFINITION'',r' °
X 'show ''π(Γ''''au α∙'''') replace■ Γ[2]ÉCR ''''replace''''''' 'endd' °
*(1997 7 13 12 28 56 532) °
Fround ÉFX 'U╜V round W' 'Σ Half adjust to V th decimal' °
X 'U╜(╛0.5+W⌡10*V)÷10*V' °
*(1997 7 27 13 0 3 268) °
Fround╢ ÉFX 'round╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "round" half adjusts the right argument at the position of °
''' '''specified by the left argument'',r' °
'show ''0 round 123.456'' ''²2 round 12345.6'' ''3 round 123.456789''' °
'show ''2 round É╜0.0001⌡?5µ100000''' °
'show ''2 round É╜2 4µ0.0001⌡?8µ100000''' °
X 'show ''²2 round É╜Γ[2]2 4µ?8µ100000''' 'showfn ''round''' 'endd' °
*(1997 6 5 13 40 14 380) °
Frule ÉFX 'V rule W' 'Σ Additional remarks on rules' °
'╕(2=ÉNC ''V'')/L ╪ V╜0' 'L:╕(~(╞W)ε∞8)/LA ╪ V rulea╞W ╪ ╕L0' °
'LA:╕(~(╞W)ε9 10 11)/LB ╪ V ruleb╞W ╪ ╕L0' °
'LB:╕(~(╞W)ε11+∞8)/LC ╪ V rulec╞W ╪ ╕L0' °
'LC:╕(~(╞W)ε19+∞10)/LD ╪ V ruled╞W ╪ ╕L0' °
'LD:╕(30 31 32 33 34 35=╞W)/L30,L31,L32,L33,L34,L35' °
'''This rule number is undefined'' ╪ ╕' '╕(0=V)/L0' 'L30:╕(V>1)/L30X' °
''' RULE 30. The length of left argument to both TAKE and DROP must °
''' °
''' equal the rank of the right argument. The exception: a' °
'' °
''' scalar left argument can be applied to a right argument °
''' ''' vector.'',2µr' '╕(0=V)/L0' °
'L30X:''A zero is permissible on both take and drop. A null vector is °
not.''' '╕L0' 'L31:╕(V>1)/L31X' °
''' RULE 31. For TAKE and DROP with axis specification, every''' °
''' integer in the left argument must be matched with''' °
''' a valid axis in brackets. Axes may not be duplicated.'' °
' °
''' The length of the left argument may be less than the''' °
''' rank of the right argument with axis specification.'',2 °
µr' '╕(0=V)/L0' 'L31X:''Any axes not specified are left unchanged.''' °
'╕L0' 'L32:╕(V>1)/L32X' °
''' RULE 32. Monadic Take extracts the contents of the first scalar' °
'' °
''' (rank 0 array) in an array, regardless of its rank.''' °
''' It is called FIRST.'',2µr' '╕(0=V)/L0' °
'L32X:''The FIRST of an empty array returns the prototype.''' '╕L0' °
'L33:╕(V>1)/L33X' °
''' RULE 33. The each operator can be placed to the right of a''' °
''' function, or to the right of an operator. When used,''' °
''' it applies the combined function separately to every''' °
''' element of the argument.'',2µr' '╕(0=V)/L0' °
'L33X:''This operator is so powerful that it is tempting to over-use i °
t.''' °
'''As you excercise your APL2 skills, try to solve problems without''' °
'''the EACH operator as much as possible.''' '╕L0' 'L34:╕(V>1)/L34X' °
''' RULE 34. A rank 0 array, or another array can be catenated to an °
''' °
''' array. When two arrays are catenated, the matching dime °
nsion''' ''' of the two arrays must be the same.'',2µr' °
'╕(0=V)/L0' °
'L34X:''Catenation does not increase depth. The result will have the d °
epth''' '''of the component of greatest depth.'',r' °
'show ''╧3 3µ∞9'' ''╧Γ∞5'' ''╧(3 3µ∞9),Γ∞5''' '╕L0' 'L35:╕(V>1)/L35X' °
''' RULE 35. Two arrays can be catenated if their rank differs by 1. °
''' °
''' The shapes of dimensions not catenated MUST MATCH!'',2µ °
r' '╕(0=V)/L0' °
'L35X:''Naturally, to catenate along other than the last dimension, an °
axis''' '''specification can also be used here.''' 'L0:do' °
X '╕(0=µW╜1╟W)/0' '╕L' °
*(1997 6 1 12 42 53 524) °
Frulea ÉFX 'V rulea W' 'Σ Additional remarks on rules' °
'╕(2=ÉNC ''V'')/L ╪ V╜0' 'L:╕(W=∞8)/L1,L2,L3,L4,L5,L6,L7,L8' °
'''For rules not described in this lesson, see workspace INDEX''' °
'╕0' 'L1:╕(V>1)/L1X' °
'''RULE 1. For arithmetic operations a vector must be matched with a'' °
' ''' scalar, or another vector of the same length.'',2µr' °
'╕(0=V)/0' °
'L1X:''This is the first of many rules dealing with the concept of''' °
'''CONFORMABILITY. This means that elements to be processed by APL2''' °
'''must in some ways match.''' '╕0' 'L2:╕(V>1)/L1X' °
'''RULE 2. The reduction operator places the function, (specified to'' °
' °
''' its left), between all pairs of the vector. It then evaluat °
es''' ''' the resulting expression.'',2µr' '╕(0=V)/0' °
'L2X:''There is more to this, but at this stage the rule is essentiall °
y''' '''correct.''' '╕0' 'L3:╕(V>1)/L1X' °
'''RULE 3. All APL2 expressions are evaluated from right to left'',2µr °
' '╕(0=V)/0' °
'L3X:''This rule is valid in APL, which is the earlier version of APL2 °
.''' °
'''For APL2, the rule has been restated in a totally different way.''' °
'''However until we introduce some concepts that are new to APL2, the' °
'' '''newer form reduces to RULE 3 as stated.''' '╕0' 'L4:╕(V>1)/L1X' °
'''RULE 4. Vectors in APL2 can have lengths of zero and one.'',2µr' °
'╕(0=V)/0' °
'L4X:''This is the first concept that begins to introduce the idea tha °
t no''' °
'''matter what the APL expression, if it is valid, it must produce a'' °
' °
'''valid APL2 object. (Shades of which came first, the chicken or the °
egg)''' '╕0' 'L5:╕(V>1)/L1X' °
'''RULE 5. The shape of a variable is a vector. The shape of a vector' °
'' ''' is a vector of length 1. The shape of a scalar is a''' °
''' vector of length zero.'',2µr' '╕(0=V)/0' °
'L5X:''The left argument of RESHAPE is by definition a vector. If APL2 °
is''' °
'''to be internally consistent, the inverse operation to RESHAPE (whic °
h''' '''is indeed SHAPE) MUST return the same type of object.''' '╕0' °
'L6:╕(V>1)/L1X' °
'''RULE 6. Reduction of a scalar returns that scalar REGARDLESS of''' °
''' the function to the left of the reduction operator.'',2µr' °
'╕(0=V)/0' °
'L6X:''Reduction BY DEFINITION reduces the RANK by one. The exception °
is''' °
'''for objects whose rank is zero. Since there is no such thing as''' °
'''negative rank, reduction is undefined for scalars, and therefore''' °
'''the result is to leave the APL2 object unchanged.''' '╕0' °
'L7:╕(V>1)/L1X' °
'''RULE 7. The reduction of a null vector produces the identity''' °
''' element of the function.'',2µr' '╕(0=V)/0' °
'L7X:''A null vector may be empty, but it still has rank equal to one. °
''' °
'''Therefore its reduction MUST be a scalar. Since there is no data''' °
'''in a null vector, the scalar must be such that it has no effect''' °
'''on the operation performed by the function: Zero added to anything' °
'' °
'''has no effect in addition; one multiplied by anything has no effect °
''' '''in multiplication; and so on.''' '╕0' 'L8:╕(V>1)/L1X' °
'''RULE 8. Parentheses can (and should) be used to modify the right''' °
''' to left rule to improve efficiency'',2µr' '╕(0=V)/0' °
'L8X:''Parentheses are used in APL2 for other purposes as well, but fo °
r''' °
'''now, we will use them just to modify the right to left rule (RULE 3 °
).''' °
'''If you place parentheses where they are not needed, APL2 will ignor °
Xe''' '''them.''' °
*(1997 6 1 12 49 37 488) °
Fruleb ÉFX 'V ruleb W' 'Σ Additional remarks on rules' °
'╕(2=ÉNC ''V'')/L ╪ V╜0' 'L:╕(9 10 11=╞W)/L9,L10,L11 ╪ ╕0' °
'L9:╕(V>1)/L9X' °
''' RULE 9: To produce a quote inside a character string, enter''' °
''' the quote twice.'',2µr' '╕(0=V)/0' °
'L9X:''This is used in most other programming languages.''' '╕0' °
'L10:╕(V>1)/L10X' °
''' RULE 10: In replication the left argument must contain only''' °
''' integers. The length of the left argument must be''' °
''' the same as the length of the right argument.'',2µr' °
'╕(0=V)/0' °
'L10X:''The left argument may also have negative integers. Only the nu °
mber''' °
'''of positive integers and zeros must add up to the length of the rig °
ht''' °
'''argument. Replicate with negative integers is not discussed here be °
cause''' °
'''the explanation requires concepts that have not yet been mentioned. °
'',r' 'show ''1 1 2 ²1 0 1 1 1 ²1 1 0 1 1/''''CALIFORNIAN''''''' '╕0' °
'L11:╕(V>1)/L11X' °
''' RULE 11: The expression inside square brackets must return''' °
''' positive integers in the range of the length of''' °
''' the indexed vector. If the expression is MISSING,''' °
''' the result is as if the brackets were missing.'',2µr' °
'╕(0=V)/0' °
'L11X:''The expression in brackets need not be a vector. It could be a °
n''' '''array as in the next example'',r' °
X 'show ''''''CALIFORNIA''''[3 3µ?9µ10]'' ''(∞4)[3 3µ∞4]''' °
*(1997 6 2 12 11 17 260) °
Frulec ÉFX 'V rulec W' 'Σ Additional remarks on rules' °
'╕(2=ÉNC ''V'')/L ╪ V╜0' °
'L:╕((11+∞8)=╞W)/L12,L13,L14,L15,L16,L17,L18,L19' 'L12:╕(V>1)/L12X' °
''' RULE 12. A scalar function is one that will produce a result on' °
'' °
''' every scalar element of a vector or array. EXAMPLES:''' °
''' + - ⌡ ÷ * are numeric scalar functions. , µ ∞ are NOT'' °
' ''' scalar functions.'',r' '╕(0=V)/0' °
'L12X:''This distinction will become clearer when we study more genera °
lized''' '''arrays.''' '╕0' 'L13:╕(V>1)/L13X' °
''' RULE 13. Scalars that work with vectors also work with arrays.'' °
,r' '╕(0=V)/0' °
'L13X:''No problem with simple scalars, but this rule may need modific °
ation''' °
'''when we deal with "rank zero arrays" that are not simple scalars.'' °
' '╕0' 'L14:╕(V>1)/L14X' °
''' RULE 14. Arrays with the same shape can be processed with scalar °
''' '''functions.'',r' '╕(0=V)/0' °
'L14X:''Arrays with distinct shapes can be processed as we shall see, °
but''' °
'''there will be restrictions, and we will use new operators.''' '╕0' °
'L15:╕(V>1)/L15X' °
''' RULE 15. The number of semicolons inside brackets must equal the °
''' ''' rank of the array MINUS 1.'',r' '╕(0=V)/0' °
'L15X:''There is no further generalization to this rule.''' '╕0' °
'L16:╕(V>1)/L16X' °
''' RULE 16. An axis specification can be a scalar, a vector or a''' °
''' null vector.'',r' '╕(0=V)/0' °
'L16X:''Recall that null array is the ONLY bracket specification that' °
'' °
'''makes sense for a scalar. We will use that property when dealing wi °
th''' '''rank 0 arrays.''' '╕0' 'L17:╕(V>1)/L17X' °
''' RULE 17. An axis specification can be any array containing''' °
''' valid integers.'',r' '╕(0=V)/0' °
'L17X:''With this rule, you can generate an APL2 object of arbitrary'' °
' '''rank.''' '╕0' 'L18:╕(V>1)/L18X' °
''' RULE 18. The shape of the result of axis specification is the''' °
''' catenation of the shapes of expressions inside brackets °
.''' °
''' If the expression for an axis is missing, the shape for °
''' ''' that axis is unchanged.'',r' '╕(0=V)/0' °
'L18X:''This is merely the rule for implementation of rule 17.''' °
'╕0' 'L19:╕(V>1)/L19X' °
''' RULE 19. Simple reduction of arrays removes its last dimension.' °
X',r' '╕(0=V)/0' 'L19X:''This is a generalization of rule 2.''' '╕0' °
*(1997 6 3 12 4 29 284) °
Fruled ÉFX 'V ruled W' 'Σ Additional remarks on rules' °
'╕(2=ÉNC ''V'')/L ╪ V╜0' °
'L:╕(W=19+∞10)/L20,L21,L22,L23,L24,L25,L26,L27,L28,L29' °
'''This rule number is undefined'' ╪ ╕' 'L20:╕(V>1)/L20X' °
''' RULE 20. The depth of an APL array is defined as the maximum''' °
''' depth to reach a simple scalar.'',2µr' '╕(0=V)/0' °
'L20X:''The concept of depth provides the means of building complex da °
ta''' °
'''structures. This is the first of several rules dealing with depth.' °
'' '╕0' 'L21:╕(V>1)/L21X' °
''' RULE 21. No APL2 expression can generate a depth 1 object contai °
ning''' °
''' ONLY a scalar. (Or, a scalar can not have depth 1.)'',2 °
µr' '╕(0=V)/0' °
'L21X:''This rule can be treated as an axiom of APL2. In theory it is' °
'' °
'''possible to enclose a scalar, but that would lead to a significantl °
y''' °
'''different language. EXAMPLE: The reduction of a vector must return' °
'' °
'''a scalar. Doing repeated reduction could produce enclosed scalars'' °
' °
'''that would require removal of such depths before allowing compariso °
ns.''' '╕0' 'L22:╕(V>1)/L22X' °
''' RULE 22. The depth of an array is given by the maximum length of °
''' °
''' the access vector associated with that array.'',2µr' °
'╕(0=V)/0' °
'L22X:''When you use function DISPLAY, depth can be obtained by counti °
ng''' °
'''the number of boxes you must cross from outside to reach the innerm °
ost''' '''scalar.''' '╕0' 'L23:╕(V>1)/L23X' °
''' RULE 23. Null elements of an access vector must be included to'' °
' ''' match corresponding rank zero arrays.'',2µr' °
'╕(0=V)/0' °
'L23X:''The access vector works from left to right. The leftmost eleme °
nt''' °
'''removes the outermost box, and the rightmost element removes the''' °
'''innermost box.''' '╕0' 'L24:╕(V>1)/L24X' °
''' RULE 24. The monadic disclose of a rank 0 array reveals the cont °
ents''' ''' of that array.'',2µr' '╕(0=V)/0' °
'L24X:''This is a consequence of rule 21. A simple scalar is immune to °
''' '''to the process of enclosure or disclosure.''' '╕0' °
'L25:╕(V>1)/L25X' °
''' RULE 25. The monadic disclose (without axis specification) reduc °
es''' °
''' depth by one, by adding a new last axis to the disclose °
d''' °
''' elements. FILL elements are used to complete the array. °
'',2µr' '╕(0=V)/0' °
'L25X:''The fill element for numberic arrays is zero. The fill element °
for''' °
'''character arrays is a blank. The fill element for mixed arrays in'' °
' '''APL2 will be discussed in later sessions.''' '╕0' °
'L26:╕(V>1)/L26X' °
''' RULE 26. Simple disclose requires that all components of a neste °
d''' °
''' array have the same rank (or be rank 0 arrays).'',2µr' °
'╕(0=V)/0' °
'L26X:''We use the phrase ''''simple disclose'''' because, as we will °
learn''' °
'''later, you can define your own rules on how to disclose nested''' °
'''arrays.''' '╕0' 'L27:╕(V>1)/L27X' °
''' RULE 27. Forms can be equivalent only if all rank 0 arrays conta °
in''' °
''' the same rank and shape (or rank 0 arrays)--recursively °
--'',2µr' '╕(0=V)/0' °
'L27X:''Earlier we discussed functions that are dual. These are one to °
''' °
'''one transformations of data. Equivalent forms can be thought of as' °
'' '''a kind of dual representation of data structures.''' '╕0' °
'L28:╕(V>1)/L28X' °
''' RULE 28. A zero in a partition vector will remove the associated °
''' ''' element.'',2µr' '╕(0=V)/0' °
'L28X:''The components of a partition vector must be positive integers °
or''' °
'''zero. The presence of a zero is treated much the same as in boolean °
''' '''reduction.''' '╕0' 'L29:╕(V>1)/L29X' °
''' RULE 29. Each place in the partition vector, where the value''' °
''' INCREASES marks a partition.'',2µr' '╕(0=V)/0' °
'L29X:''A partition must ocurr BETWEEN two consecutive elements. These °
''' '''need not be simple scalars'',r' °
X 'show ''DISPLAY (1 1 2 2)Γ(1 2) ''''AB'''' (3 4) ''''C''''''' '╕0' °
*(1997 7 13 12 28 57 536) °
Fshow ÉFX '╢V show ╢W;╢T;╢B' 'Σ Display and execute ╢W' °
'╢T╜(0=ÉNC ''╢V'')doif ''╢V╜0''' °
'╕((0=╧╢W)doif ''show ╢W,'''' '''''')/0' °
'╕((1<╧╢W)doif ''╢V show ■╢W'')/0' ''' '',╢W' °
X '╕((╢V^'':''ε╢W)doif ''╢T╜evaldd ╢W'')/L0' '''ÉEM'' ÉEA ╢W' 'L0:do' °
*(1997 8 8 13 11 39 384) °
Fshowdd ÉFX 'u╜showdd w;a;b;c;r' °
'Σ Display a direct definition function' °
'╕((1=╧w)doif ''u╜showdd Γw'')/u╜0' °
'╕((3⌠ÉNC╞w)doif ''(ε╞w),'''' is not a function'''''')/0' °
'c╜Γ[2]ÉCR╞w' 'c╜notb(2╞c),(Γ''aw α∙'')replace■2╟c' °
'╕((~''ΣDD''╧3╞2πc)doif ''''''Not a direct definition function'''''')/ °
0' 'u╜1' 'b╜('' ''⌠╞c)Γ╞c' 'a╜'' ''' 'r╜2╟3πc' °
'╕((3=µc)doif ''a,(╞w),'''':'''',r,(3<µ2πc)/'''' Σ'''',3╟2πc'')/0' °
'a╜a,(╞w),'':'',(2╟5πc),'':''' 'b╜(+\r=''('')-+\r='')''' 'b╜b∞0' °
X 'a╜a,(²3╟(b-1)╞3╟r),'':'',2╟»(b+1)╟r' 'a,(3<µ2πc)/'' Σ'',3╟2πc' °
*(1997 8 8 13 20 30 384) °
Fshowdd╢ ÉFX 'showdd╢;FOO;FOO2' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "showdd" is a subroutine in "evaldd". It is invoked''' °
'''whenever the keyboard entry is a label ending with a colon (:).''' °
'''The right argument should be the name of a function that has been'' °
' °
'''fixed using the Direct Definition feature of "evaldd". The function °
''' °
'''returns a 0 and an appropriate message, if the name is not valid. I °
f''' °
'''all goes well, the function returns a 1. The boolean value returned °
''' °
'''by "showdd" is used by function "evaldd" to determine its next acti °
on.'',r' 'show ''showdd ''''FOO''''''' °
'''A function that has been defined using "evaldd" contains the sequen °
ce''' °
'''ΣDD in line 1. If this sequence is absent, "showdd" will also fail' °
',r' 'show ''showdd ''''showdd''''''' °
'''We can use "evaldd" to define function FOO'',r' °
'1 show ''FOO:∞∙'' ''ÉNC ''''FOO'''''' ''FOO 4'' ''showdd ''''FOO''''' °
'' °
'1 show ''FOO2:''''no'''':∙:''''yes'''''' ''ÉNC ''''FOO2'''''' ''FOO2 °
4<5'' ''showdd ''''FOO2''''''' °
'''(The colon is removed by "evaldd".) Normally the right argument is °
a''' °
'''nested vector since the comment line gets attached first in "evaldd °
".'',r' 'show ''showdd ''''FOO'''' ''''ΣDD''''''' °
'''For more information on Direct Definition, try "evaldd╢".''' °
X 'endd' °
*(1997 7 13 12 28 57 536) °
Fshowfn ÉFX 'U╜V showfn W;F;N;T;ÉIO' 'Σ Simulate ╖W[É]' °
'T╜(0=ÉNC ''V'')doif ''V╜0''' 'ÉIO╜0' °
'U╜r,'' '',''╖'',W,''[É]'',(╞V)╞''╖''' 'N╜1╞µF╜ÉCR W' 'N╜«∞N' °
'N╜(N⌠'' '')ΓN' 'F╜(π''['',■N,■Γ''] ''),F' °
'T╜(1<µ,V)doif ''F╜F[1╟V;]'' ''U╜''''''''''' 'U╜²1╟U,r,,F,r' °
X 'U╜((-+/^\'' ''=ΦU)╟U),('' ╖'')[╞V],r' °
*(1997 7 28 12 46 20 520) °
Fshowfn╢ ÉFX 'showfn╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "showfn" is used in documentation to display portions of u °
ser''' '''defined functions'',r' °
'''The function is dyadic and returns the desired display'',r' °
'show ''1 showfn ''''showfn''''''' °
'''The right argument is the name of the defined function or operator. °
''' °
'''The left argument is optional, and if absent it is set to zero.''' °
'''If the left argument is a vector, the numbers past the first''' °
'''(boolean) value specify the lines of code to display'',r' °
'show ''0 1 11 showfn ''''showfn''''''' °
'''If the left argument begins with zero, the trailing ╖ is ommited,'' °
' °
'''making it possible to display new lines of code not present in the' °
'' '''function'',r' °
'show ''(0 1 showfn ''''showfn''''),''''[1.1] Σ Insert a new line here °
''''''' °
'''To display the header, it may be desirable to remove the leading''' °
'''[0]. (note that the result of "showfn" is a simple character vector °
X)'',r' 'show ''²31╞4╟0 0 showfn ''''showfn''''''' 'endd' °
*(1997 7 27 14 9 5 316) °
Fshow╢ ÉFX 'show╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "show" is used in documentation to simulate the entry of'' °
' '''an APL2 expression at the terminal.'',r' °
'''The function is ambivalent and has no result. The right argument''' °
'''is the expression to be evaluated. It must be a character string.'' °
' °
'''The right argument can also be a nested vector. If it is, "show" wi °
ll''' °
'''be applied to each component separately. If the left argument is''' °
'''absent, the default is zero. A one in the left argument allows the' °
'' °
'''evaluation of DIRECT DEFINITIONS. Invalid APL2 expressions will''' °
'''return the appropriate error message.''' 'do' °
'''EXAMPLES (press Enter TWICE to continue):'',r' °
'show ''show ''''∞5'''''' ''show ''''?100'''' ''''∞4''''''' °
'''To display a direct definition, a 1 must be placed in the left argu °
ment'',r' °
'show ''1 show ''''FOO:∞∙'''''' ''show ''''FOO 4'''''' ''1 show ''''FO °
O:''''''' 'showfn ''show''' °
'''Line [2] sets V╢ to 0 if function "show" is used monadically. In''' °
'''line [3], if the right argument is of depth 0, catenate a blank''' °
'''to W╢ and re-enter "show". In line [4] if the right argument is''' °
'''nested, apply "show" to each component of W╢. In line [5] display'' °
' °
'''the expression to be evaluated. In line [6] test for a colon, and i °
f''' °
'''present AND the left argument is 1, apply function "evaldd" to W╢.' °
'' °
'''Then go to line [8]. On line [7] evaluate the expression W╢ with th °
e''' °
'''Execute alternate command. Line [8] is a pause allowing user to''' °
X '''enter additional expressions.''' 'endd' °
*(1996 4 6 15 59 49 596) °
Fsimdd ÉFX 'u╜simdd w;e' 'Σ Direct definition mode' 'u╜0' °
'╕((0⌠ÉNC╞w)doif ''''''Already defined'''''')/0' 'e╜''α''ε2πw' °
'w[2]╜Γ''u╜'',''α∙ aw'' replace 2πw' 'w╜w[1 3 2]' °
X 'w[1]╜Γε''u╜'',(e/''a ''),w[1],'' w''' 'u╜╧ÉFX w' °
*(1997 7 28 12 49 32 580) °
Fsimdd╢ ÉFX 'simdd╢;FOO' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "simdd" is a subroutine of "evaldd". It completes the''' °
'''process of fixing definition of a SIMPLE DIRECT DEFINITION. This''' °
'''is one where the function label is followed by a single APL2''' °
'''expression'',r' °
'show ''simdd ''''FOO'''' ''''∞∙'''' ''''ΣDD Simple DD''''''' °
'''The left argument to "simdd" is a nested vector with three componen °
ts:''' °
'''The function name, the APL2 expression and a comment line'',r' °
'show ''ÉNC ''''FOO'''''' ''FOO 4''' '1 show ''FOO:''' °
'''For more information on Direct Definition, try "evaldd╢".''' °
X 'endd' °
*(1992 6 3 9 59 17 424) °
Ftab ÉFX 'U╜V tab W;T;A;B;C;D;E;F;G;M;ÉPW' 'Σ Tabulate list W' °
'T╜(0=ÉNC ''V'')doif ''V╜0''' 'M╜''Invalid data for tabulation''' °
'V╜4╞V' 'ÉPW╜130╛30⌐G╜V[2]+79⌡V[2]=0' °
'L1:╕((1<╧W)doif ''''''W╜∞0'''' ÉEA ''''W╜πW'''''')/L1' °
'╕(((0=µεW)δ2<µµW)doif ''U╜(~V╧4╞0)/M'')/0' °
'T╜(1≥µµU╜«W)doif ''U╜πW╜(U⌠'''' '''')ΓU''' °
'T╜(0<V[1])doif ''U╜(«(Φ1,╞µW)µ(V[3]µ'''' ''''),∞(╞µW)-V[3]),'''' '''' °
,U''' '╕(G<30)/0' 'T╜(F╜µεV[4])+C╜1╟B╜µA╜(V[3],0)╟U' °
'T╜⌐(1╞B)÷1⌐╛(ÉPW+F)÷T' 'U╜(E╜(V[3],C)╞U),[1](B╜T,1╟B)╞A' °
'''D╜εV[4]'' ÉEA ''D╜ÉAV[εV[4]+33⌡V[4]=0]''' 'L0:A╜(T,0)╟A' °
X '╕(0=1╞µA)/0' 'U╜U,(((T+V[3]),µD)µD),E,[1]B╞A' '╕L0' °
*(1997 7 31 12 54 12 532) °
Ftab╢ ÉFX 'tab╢' 'Σ Copyright Z V Jizba, 1992' °
'''When an APL2 variable contains a large amount of data, the default' °
'' °
'''display may cause the screen to roll. Often this data overflow on t °
he''' °
'''screen can be avoided by re-arranging the data into more than one'' °
' °
'''column. Function "tab" is a utility to do just such folding into tw °
o''' '''or more columns.'',r' °
'''The function is dyadic, and returns the data as a character table. °
The''' °
'''right argument contains the data to be tabulated. The data can be'' °
' °
'''numeric, character or mixed. It can be a vector, a nested vector,'' °
' °
'''an array or a nested array. The optional left argument specifies th °
e''' °
'''processing parameters. When missing, "tab" takes all defaults.'',r' °
'do' '''The contents of the left argument V'',r' °
'''V[1] 0=tabulate data as is (default); 1=add sequence numbers''' °
'''V[2] Page width (default is 79)''' °
'''V[3] Number of rows to be replicated as header (default is 0)''' °
'''V[4] Characters to be used between columns. V[4] may be numeric''' °
''' (elements of ÉAV) or character. Default is a blank.'',r' °
'do' '''Here are examples of the usage of function "tab"'',r' °
''' 1. Tabulation of numeric vectors'',r' 'show ''tab ∞50''' °
''' 2. Tabulation of character vectors'',r' °
'show ''tab ''''The government has the power to impose taxes.''''''' °
''' 3. Tabulation of nested numeric vectors. Note single space separat °
ion''' ''' between consecutive vectors'',r' 'show ''tab 3,/∞50''' °
''' 4. Tabulation of nested character vectors'',r' °
'show ''tab 20µ''''one'''' ''''two'''' ''''three'''' ''''four'''' '''' °
five'''' ''''six''''''' ''' 5. Tabulation of numeric arrays'',r' °
'show ''tab 9 3µ3⌡/∞29''' ''' 6. Tabulation of character arrays'',r' °
'show ''tab π20µ''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FOUR'''' ''' °
'FIVE'''' ''''SIX''''''' °
'''With a left argument, additional options are possible'',r' °
''' 7. Numbering individual row entries in a list or table'',r' °
'show ''1 tab ''''The government has the power to impose taxes.''''''' °
'show ''1 tab π20µ''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FOUR'''' ' °
'''FIVE'''' ''''SIX''''''' °
''' 8. Specifying the width of the table. (Minimum page width is 30)'' °
,r' °
'show ''0 30 tab ''''The government has the power to impose taxes.'''' °
''' °
'show ''1 30 tab ''''The government has the power to impose taxes.'''' °
''' ''' 9. Specifying the number of lines in the header'',r' °
'show ''0 40 2 tab ''''HEAD'''' ''''²²²²'''',20µ''''ONE'''' ''''TWO''' °
' ''''THREE''''''' °
'''10. Specifying the character(s) to separate columns'',r' °
'show ''1 0 0 125 tab ''''The government has the power to impose taxes °
.''''''' °
'''Multiple characters as separators can be defined several ways'',r' °
'show ''0 0 0 (33 125 33) tab 20µ''''ONE'''' ''''TWO'''' ''''THREE'''' °
''''FOUR''''''' °
'show ''0 0 0 (0 125 0) tab 20µ''''ONE'''' ''''TWO'''' ''''THREE'''' ' °
'''FOUR''''''' °
'show ''0 0 0 '''' | '''' tab 20µ''''ONE'''' ''''TWO'''' ''''THREE'''' °
''''FOUR''''''' °
'''If the array to be tabulated is empty, a message appears. However,' °
'' °
'''if the left argument has all defaults, there will be no message'',r °
' 'show ''tab ∞0'' ''1 tab ∞0''' °
'''The algorithm is simple and straight forward'',r' °
'0 0 1 2 4 5 showfn ''tab''' °
'r,''Lines [2] and [4] establish the defaults on the left argument. Li °
ne''' °
'''[5] insures that the minimum and maximum page widths allowed by APL °
2''' '''are not violated.'',r' 'do' '0 3 6 7 showfn ''tab''' °
'r,''Lines [6] and [7] insure that the right argument is not nested an °
d''' °
'''does not have a rank greater than 2. Line [3] assigns the empty arr °
ay''' °
'''message. If the array is empty, and if the left argument does not h °
ave''' °
'''four zeros, the message M will be displayed on exit from line [7].' °
',r' 'show ''tab (2 2µ∞4) (3 4) 5'' ''1 tab 2 3 4µ∞24''' °
'0 8 showfn ''tab''' °
'r,''Line [8] converts simple vectors to arrays'',r' °
'0 9 showfn ''tab''' °
'r,''Line [9] inserts line numbers in front of table'',r' 'do' °
'0 10 showfn ''tab''' °
'r,''If the given width is less than 30, a single column is returned.' °
',r' °
'show ''1 29 tab ''''The government has the power to impose taxes.'''' °
''' '0 10 11 12 showfn ''tab''' °
'r,''Lines [11] and [12] find the number of columns of the table'',r' °
'0 13 14 showfn ''tab''' °
'r,''Line [13] formats the first column and captures the header, if an °
y.''' °
'''Line [14] determines the nature of the column separation characters °
.'',r' 'do' '0 15 16 17 18 showfn ''tab''' °
'r,''Lines [15-18] build up the rest of the table.''' 'do' °
'''PROBLEMS'',r' °
'''The following situations fail to provide a satisfactory result'',r' °
'''1. Entering invalid numeric values in V[4] may cause table overflow °
.'',r' °
'show ''1 0 0 123.5 tab 8µ''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FO °
UR''''''' '''2. Mixed vectors do not produce clean tables''' °
'show ''tab ''''TITLE'''' 2 3 4 5 6''' °
'show ''1 50 2 '''' | '''' tab ''''TOP'''' ''''²²²'''',?10µ100''' °
X 'endd' °
*(1997 7 13 12 28 59 544) °
Ftest ÉFX 'U╜V test W;P' °
'Σ Describe problem in W, (correct answer in V)' 'U╜2' 'L1:W' °
'É╜'' ''' 'P╜æ' '''╕L0'' ÉEA ''P╜»P''' '╕(V╧P)/0' °
X 'L0:╕(0=U╜U-1)/0' '''Incorrect. Try again''' '╕L1' °
*(1997 7 28 12 52 31 588) °
Ftest╢ ÉFX 'test╢' 'Σ Z V Jizba, UTILITY, April 6, 1991' °
'''Function "teset" is a prototype (eventually more features should be °
''' °
'''added) to be used in teaching APL2. The right argument describes''' °
'''an APL2 problem to be solved by the student. The left argument''' °
'''contains the correct response. An APL2 prompt waits for a keyboard' °
'' °
'''entry, and if this evaluates to the correct result, the function''' °
'''returns a 2. If on the first attempt the evaluation fails, the''' °
'''student gets a second chance, but then the score is a 1. After two' °
'' '''failures, the score is 0.''' 'do' °
'''In the following examples first try the correct response (∞5). Then °
''' '''in the second example try an incorrect expression first.'',r' °
'show ''(∞5) test ''''Generate the vector: 1 2 3 4 5''''''' °
X 'show ''(∞5) test ''''Generate the vector: 1 2 3 4 5''''''' 'endd' °
XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ °
*(1997 7 13 12 28 59 544) °
Fvec ÉFX 'U╜vec' 'Σ Draw 2d vector in plane' °
'U╜r,r,''2- +'',r '': °'',r,''1- °'',r' °
X 'U╜U,'' : °'',r,''0|....|....|'',r,'' 0 1 2'',r' °