home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
teachapl.zip
/
TEACH.ZIP
/
TEACH18A.ATF
< prev
next >
Wrap
Text File
|
1997-09-19
|
62KB
|
762 lines
XNÉIO 0 1 °
XNÉCT 0 1E²13 °
XCÉFC 1 6 .,*0_² °
XNÉRL 0 16807 °
XCÉPR 1 1 °
XCÉLX 1 5 TEACH °
*(1996 4 6 16 10 1 212) °
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 8 19 11 27 39 484) °
FCtoN ÉFX 'U╜V CtoN W;B;D;E;T' 'Σ Convert character W to numeric' °
'E╜''Right argument is not a valid table''' '╕(0⌠ÉNC ''V'')/L0 ╪ V╜0' °
'L0:B╜'' ''⌠W╜W,'' ''' '╕(1≥µµW)/L1 ╪ B╜δ≡B ╪ U╜(,(D╜µW)µB)Γ,W ╪ ╕L2' °
'L1:U╜BΓ,W ╪ D╜µU' 'L2:B╜+/(B⌠1╟B,0)/B' 'U[(^/■'' ''=U)/∞µU]╜Γ«V' °
'''U╜0'' ÉEA ''U╜»■U''' '╕(1=╧U)/L3 ╪ E ╪ ╕0' °
X 'L3:╕((µεU)=⌡/B,²1╟D)/L4 ╪ U╜∞0 ╪ E ╪ ╕0' 'L4:U╜((²1╟D),B)µU' °
*(1997 8 19 11 27 43 500) °
FCtoN╢ ÉFX 'CtoN╢;R;ONE' 'Σ Blueprint for function CtoN' °
'Σ Z. V. Jizba, workspace TEACH18, April 6, 1991' °
'''Function CtoN will take a character array W with''' °
'''numeric data, and convert it to a numeric array.''' °
''' U╜V CtoN W;D;T''' °
'''Numbers preceeded by a minus sign will be treated as''' °
'''negative numbers. Blanks in places where numbers are''' °
'''expected, will be treated as zeros by default. An''' °
'''optional left argument is available to over-ride this''' °
'''"zero default".'',r' 'do' '''THE ALGORITHM OF CtoN'',r' °
'''Here is a listing of function CtoN'',r' °
'show ''1 showfn ''''CtoN''''''' °
'''If the left argument is not given, a default value of zero''' °
'''assigned to V in line [3]. Next, blanks are identified in''' °
'''line [4] as before. The resulting pattern is replicated for''' °
'''all rows of the array and the ravelled array is partitioned''' °
'''into its tabular elements in line [5]. For scalars and vectors''' °
'''partition is made in line [6]. The number of columns is obtained''' °
'''in line [7] and blank entries are replaced by the default value''' °
'''V in line [8].''' 'do' °
'''At this point each element of the nested vector should''' °
'''contain an expression that will evaluate to a single number.'',r' °
'''The next step is to evaluate each element of this nested''' °
'''vector. If one or more entries fail this evaluation, a zero''' °
'''is returned on line [9]. On line [10], if the execute has''' °
'''failed, or the argument is a scalar, display E and exit. If''' °
'''the numeric vector has the wrong length [11](i.e. one or more''' °
'''entries return two or more values), then also display E and exit.'' °
,r' '''The numeric table is returned if all these tests are passed''' °
'do' '''EXAMPLES:'',r' °
'show ''DISPLAY R╜«3 3µ∞9'' ''DISPLAY 10+CtoN R''' °
'''A character array containing numeric data is converted to a''' °
'''numeric array.''' 'do' 'show ''R╜2 6µ'''' 12 -5-13 13''''''' °
'show ''R'' ''CtoN R''' °
'''Negative numbers (with minus signs) are converted correctly''' °
'do' 'show ''R[2;2]╜'''' '''''' ''R'' ''CtoN R''' °
'''The conversion works even if the minus sign is not next''' °
'''to the numeric value''' 'do' °
'show ''R[1;2 3]╜'''' '''''' ''R[2;2]╜''''1'''''' ''R''' °
'''By blanking out the entry in row 1, column 1, we form an''' °
'''incomplete table''' 'do' 'show ''CtoN R'' ''.123 CtoN R''' °
'''Applying CtoN monadically the empty slot is assigned a''' °
'''value of zero. This can be modified using CtoN dyadically.''' 'do' °
'show ''CtoN É╜,R'' ''CtoN É╜,R,'''' ''''''' °
'''CtoN now works with vectors (but notice that -5-13 evaluates''' °
'''to 8 because this expression contains no blanks)''' 'do' °
'show ''CtoN '''' ''''''' °
'''And it produces the desired message with a blank vector''' 'do' °
'show ''R[1;1 2 3]╜''''ONE'''''' ''R'' ''CtoN R''' °
'''An undefined character string in the array produces an''' °
'''error message''' 'do' 'show ''ONE╜1'' ''CtoN R''' °
X '''But when the label is assigned a value, CtoN works.''' °
*(1997 9 14 12 30 44 504) °
XFDISCLAIMER ÉFX 'DISCLAIMER' 'Σ Copyright statement' 'disclaimer' °
*(1996 4 6 16 10 1 212) °
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' °
*(1996 4 6 16 10 1 212) °
FEXIT ÉFX 'EXIT' 'Σ Exit from function' '''To log off type: )OFF''' °
X '╕' °
AFD╜('U╜V CtoN W;B;D;E;T')('Σ Convert character W to numeric')('E╜''Rig °
ht argument is not a valid table''')('╕(0⌠ÉNC ''V'')/L0 ╪ V╜0')('L0:B╜' °
' ''⌠W╜W,'' ''')('╕(1≥µµW)/L1 ╪ B╜δ≡B ╪ U╜(,(D╜µW)µB)Γ,W ╪ ╕L2')('L1:U╜ °
BΓ,W ╪ D╜µU ')('L2:B╜+/(B⌠1╟B,0)/B')('U[(^/■'' ''=U)/∞µU]╜Γ«V')('''U╜0' °
' ÉEA ''U╜»■U''')('╕(1=╧U)/L3 ╪ E ╪ ╕0')('L3:╕((µεU)=⌡/B,²1╟D)/L4 ╪ U╜∞ °
X0 ╪ E ╪ ╕0')('L4:U╜((²1╟D),B)µU') °
AFN╜('CtoN╢;R;ONE')('Σ Blueprint for function CtoN')('Σ Z. V. Jizba, wo °
rkspace TEACH18, April 6, 1991')('''Function CtoN will take a character °
array W with''')('''numeric data, and convert it to a numeric array.'' °
')(''' U╜V CtoN W;D;T''')('''Numbers preceeded by a minus sign will °
be treated as''')('''negative numbers. Blanks in places where numbers °
are''')('''expected, will be treated as zeros by default. An''')('''op °
tional left argument is available to over-ride this''')('''"zero defaul °
t".'',r')('do')('''THE ALGORITHM OF CtoN'',r')('''Here is a listing of °
function CtoN'',r')('show ''1 showfn ''''CtoN''''''')('''If the left ar °
gument is not given, a default value of zero''')('''assigned to V in li °
ne [3]. Next, blanks are identified in''')('''line [4] as before. The r °
esulting pattern is replicated for''')('''all rows of the array and the °
ravelled array is partitioned''')('''into its tabular elements in line °
[5]. For scalars and vectors''')('''partition is made in line [6]. The °
number of columns is obtained''')('''in line [7] and blank entries are °
replaced by the default value''')('''V in line [8].''')('do')('''At th °
is point each element of the nested vector should''')('''contain an exp °
ression that will evaluate to a single number.'',r')('''The next step i °
s to evaluate each element of this nested''')('''vector. If one or more °
entries fail this evaluation, a zero''')('''is returned on line [9]. O °
n line [10], if the execute has''')('''failed, or the argument is a sca °
lar, display E and exit. If''')('''the numeric vector has the wrong len °
gth [11](i.e. one or more''')('''entries return two or more values), th °
en also display E and exit.'',r')('''The numeric table is returned if a °
ll these tests are passed''')('do')('''EXAMPLES:'',r')('show ''DISPLAY °
R╜«3 3µ∞9'' ''DISPLAY 10+CtoN R''')('''A character array containing num °
eric data is converted to a''')('''numeric array.''')('do')('show ''R╜2 °
6µ'''' 12 -5-13 13''''''')('show ''R'' ''CtoN R''')('''Negative number °
s (with minus signs) are converted correctly''')('do')('show ''R[2;2]╜' °
''' '''''' ''R'' ''CtoN R''')('''The conversion works even if the minus °
sign is not next''')('''to the numeric value''')('do')('show ''R[1;2 3 °
]╜'''' '''''' ''R[2;2]╜''''1'''''' ''R''')('''By blanking out the entry °
in row 1, column 1, we form an''')('''incomplete table''')('do')('show °
''CtoN R'' ''.123 CtoN R''')('''Applying CtoN monadically the empty sl °
ot is assigned a''')('''value of zero. This can be modified using CtoN °
dyadically.''')('do')('show ''CtoN É╜,R'' ''CtoN É╜,R,'''' ''''''')(''' °
CtoN now works with vectors (but notice that -5-13 evaluates''')('''to °
8 because this expression contains no blanks)''')('do')('show ''CtoN '' °
'' ''''''')('''And it produces the desired message with a blank ve °
ctor''')('do')('show ''R[1;1 2 3]╜''''ONE'''''' ''R'' ''CtoN R''')('''A °
n undefined character string in the array produces an''')('''error mess °
age''')('do')('show ''ONE╜1'' ''CtoN R''')('''But when the label is ass °
Xigned a value, CtoN works.''') °
*(1996 4 6 16 10 1 212) °
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 8 19 11 25 17 388) °
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 the cursor on a blank line''' °
''' 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╜5),'' components named TEACHx, whe °
re''' '''the x stands for a digit:'',r' 'I╜0' °
'L0:T╜''TEACH'',(«I╜I+1)' 'T,'' '',1╟notb(É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 prevous pages.''' °
'do' '''RESOURCES'',r' °
'''You may also enter ONE of the following words at a time'',r' °
'''REVIEW To review previous lesson''' °
X '''V TIME W Measure execution time of W repeated V times''' 'endd' °
*(1997 7 17 12 40 41 536) °
FTEACH ÉFX 'TEACH' 'Σ Start lesson #18: APL2 by Zdenek V JIZBA' °
'exit ''TEACH''' 'initialize' 'TEACH1 Σ Developing new functions' °
'TEACH2 Σ Documentation utility functions' °
'TEACH3 Σ Building a blueprint function' °
'TEACH4 Σ Start over by re-designing the utility' °
X 'TEACH5 Σ A new blueprint function' 'problems' °
*(1997 7 13 11 55 23 504) °
FTEACH1 ÉFX 'TEACH1;D;F;FN' °
'Σ Developing test and documentation function' °
'''In lesson 17 we studied ways to optimize APL2 code. In this lesson' °
'' °
'''we will suggest ways to improve the process of defining new APL2''' °
'''functions and operators.'',r' ''' EDITORIAL COMMENTS'',r' °
'''Most of the time, when considering writing a function, one simply'' °
' '''starts by deciding on its name, and on contents of the header.''' °
'''Then, it is often just a matter of developing the APL expressions'' °
' °
'''that will lead to the desired result. Once the function is complet °
e,''' °
'''it is also a good idea to thoroughly test and document it.'',r' °
'''Many people document functions by adding comments. Functions are te °
sted''' '''without leaving any trace of the kind of testing.''' 'do' °
'''In my opinion a well documented function should not only describe'' °
' °
'''its objective, but also should describe the kinds of tests that it' °
'' °
'''has passed. In this way, it is possible to determine the scope of' °
'' °
'''validity of the function. What is meant by scope? A function may' °
'' °
'''work fine for all the test cases that the developer has thought of, °
''' °
'''but may not work for other equally valid cases that were overlooked °
''' '''or may not even have been considered.'',r' °
'''Suppose we wish to develop a function to convert character tables'' °
' °
'''to numeric array, but fail to test it for a table containing blanks °
''' '''only. The question of scope is: should we have done so, and''' °
'''if not, will the function still work with an array of all blanks?'' °
' 'F╜'' "CtoN" '' ╪ D╜'' "CtoN╢" ''' 'do' °
'''There should be some discipline in the development of new user defi °
ned''' °
'''APL functions. In this lesson we will introduce one such discipline °
.''' °
'''We will simulate the process of defining a function to convert a''' °
'''character array to its numeric equivalent. We will call this functi °
on''' 'F,''and also define function'',D,''a kind of BLUEPRINT.'',r' °
'''We will illustrate the process of designimg the blueprint first, th °
en''' °
'''defining'',F,''. Using'',D,''we will test'',F,''and find it lacking °
.''' °
'''This will illustrate what frequently happens. A first attempt is li °
kely''' °
'''to produce an inadequate function. At this point it is very temptin °
g to''' °
'''continue to "improve" the function by adding more lines of code.''' °
'''Given the insight gained in the first try, it may be far more usefu °
l''' °
'''to scrap the function and start all over. We will re-define'',F,''a °
nd''' °
'''get rid of most of'',(²1╟D),''. Finally we will end with a reasonab °
ly''' '''useful function'',F,''and a well documented'',(²1╟D),''.''' °
'do' °
'show ''FN╜''''CtoN╢;R;ONE'''' ''''Σ Blueprint for function CtoN'''''' °
' °
'''The function is niladic since it merely describes an APL2 object. I °
t''' °
'''may however produce SIDE EFFECTS. What do we mean by side effects?' °
'' °
'''These could include generation of variables, evaluation of APL2''' °
'''expressions using defined functions, storage or retrieval of data f °
rom''' °
'''files, activation of the printer, or any other activity outside of °
the''' '''domain of APL2.''' 'do' °
'''It is important therefore to isolate such side effects from the''' °
'''workspace. Normally this is done by localizing the environment by'' °
' °
'''placing pertinent labels in the header, and by putting other data'' °
' '''in temporary storage (see PUSH and PULL in lesson 15).'',r' °
'show ''FN╜FN,Γ''''Σ Z. V. Jizba, workspace TEACH18, April 6, 1991'''' °
''' °
'''The name of the originator, date and the workspace where the APL2'' °
' °
'''object was first defined should be available on the documentation'' °
' °
'''function. It is placed there as a comment since it has no direct''' °
'''bearing on the use of the blueprint function. (If the function is'' °
' '''redefined by someone else, or moved to another workspace, then''' °
'''more comment lines should be added, The older ones should not be''' °
X '''replaced.)''' 'endd' °
*(1997 7 13 12 4 40 372) °
FTEACH2 ÉFX 'TEACH2;T' °
'Σ Describe utility functions that are useful in documentation' °
'''UTILITY FUNCTIONS'',r' °
'''Before we continue defining blueprint function CtoN╢, we must''' °
'''describe several utility functions in this workspace. (We have''' °
'''already described these in lesson 16, but we repeat the description °
s''' '''here to refresh your memory)'',r' °
'''Incidentally, all utility functions are fully documented in workspa °
ce''' °
'''UTILITY. On completion of this lesson, you should load UTILITY''' °
'''and explore all functions documented there.''' 'do' 'T╜'' "do" ''' °
'''Function'',T,''simulates an APL2 prompt. As long as non-blank''' °
'''expressions are entered at the keyboard,'',T,''attempts to evaluate °
''' °
'''them. When only blanks are entered (or just Enter is pressed),'',T' °
'''exits. This function is useful in documentation, since it allows''' °
'''the user to try out sample expressions containing the function that °
''' '''is described.''' 'do' °
'''Function "show" simulates the keyboard entry of an APL2 expression. °
''' °
'''It is used in documentation to illustrate how a function is to be'' °
' '''used. The argument to show must be a string'',r' °
'show ''show ''''∞5''''''' °
'''Function "showfn" displays selected lines of a defined function.''' °
'''(This function has been generalized.) The header for it now is'',r' °
''' [B [rows]] showfn ''''fn'''''',r' °
'''The left arguments in square brackets are optional. B is a boolean' °
'' °
'''value. A one asks for the display of leading and trailing ╖. Option °
ally''' °
'''the boolean scalar may be followed by numeric integer vector giving °
''' '''the line numbers (0 index origin) to be displayed'',r' °
'show ''1 showfn ''''do'''''' ''0 2 3 showfn ''''do''''''' °
'show ''²24╞4╟0 0 showfn ''''do''''''' °
'''You will also recall the names of global variables. In particular,' °
'' ''' "r" acts as the Enter key.''' 'do' °
'''Finally we also need a utility function called "aq" to support''' °
'''this tutorial. It is needed to eliminate excessive use of quotes'', °
r' 'show ''ÉFX ''''U╜aq W'''' ''''U╜Γaddquote W''''''' °
'''Here is an example on how this function will be used'',r' °
'show ''T╜''''TEXT'''' ''''Σ Function displaying text''''''' °
'show ''DISPLAY T,Γ''''''''''''Text to be displayed''''''''''''''' °
'''using "aq" avoids typing many quotes'',r' °
X 'show ''DISPLAY T,aq''''Text to be displayed''''''' 'endd' °
*(1997 8 19 11 22 57 536) °
FTEACH3 ÉFX 'TEACH3;C;T;I;FD;FT' °
'Σ Describe process of defining function CtoN' °
''' WRITING A BLUEPRINT FUNCTION'',r' °
'FN╜''CtoN╢;R;ONE'' ''Σ Blueprint for function CtoN''' °
'FN╜FN,Γ''Σ Z. V. Jizba, workspace TEACH18, April 6, 1991''' °
'''Let us now go through the process of defining BLUEPRINT function Ct °
oN╢.''' °
'''We will also develop the function CtoN at the same time.'',r' °
'''NOTE:(When we illustrate the sample blueprint function, we''' °
''' will begin and end it with a line of bars like this:)'',r' °
'ends ''BEGIN (or END)''' °
'FN╜FN,aq ''Function CtoN will take a character array W with''' °
'FN╜FN,aq ''numeric data, and convert it to a numeric array.''' °
'FN╜FN,aq '' U╜V CtoN W;D;T''' °
'FN╜FN,aq ''Numbers preceeded by a minus sign will be treated as''' °
'FN╜FN,aq ''negative numbers. Blanks in places where numbers are''' °
'FN╜FN,aq ''expected, will be treated as zeros by default. An''' °
'FN╜FN,aq ''optional left argument is available to over-ride this''' °
'FN╜FN,Γ''''''"zero default".'''',r'' ╪ r' °
'''Function CtoN╢ begins by displaying text'',r' 'show ''πFN''' °
'''This first paragraph describes the basic purpose of the function to °
''' '''be defined. It also includes a display of the header format.''' °
'do' °
'''At this point let us also define a provisional sample function CtoN °
'',r' 'FD╜''U╜CtoN W;D;T'' ''Σ Convert character array W to numeric''' °
'FD╜FD,''D╜µW'' ''T╜^≡W='''' '''''' ''D[2]╜+/~(T⌠1╟T,1)/T''' °
'FD╜FD,Γ''U╜Dµ»,W''' 'show ''ÉFX FD''' '1 showfn ''CtoN''' °
'''Line [2] finds the number of rows and columns of the character tabl °
e.''' °
'''Line [3] returns a boolean vector showing all columns that are blan °
k.''' °
'''Can we use this vector to determine how many columns of numbers the °
re''' °
'''are in the table? Clearly any string of zeros defines a column.''' °
'''So how do we count the number of such strings? One way would be to °
''' °
'''reduce all such strings to a single digit. Line [4] does just that. °
'',r' '''Let us verify the expression on line [4] with an example'',r' °
'show ''T╜1 1 0 0 0 0 1 0 0 0 1 1 1 1 0'' ''É╜I╜(T⌠1╟T,1)/T'' ''+/~I'' °
' °
'''Line [5] ravels the character array, executes it and then re-shapes °
it.''' 'do' °
'''That looks like it might work. So now we know the number of columns °
''' °
'''and rows. Before we proceed, let us try function CtoN on some data' °
',r' 'show ''DISPLAY CtoN «3 3µ∞9''' °
'''Obviously function CtoN is incorrect, but let us assume that we are °
''' '''not aware of that. We continue defining function CtoN╢'',r' °
'show ''FN╜FN,Γ''''show ''''''''CtoN «3 3µ∞9''''''''''''''' °
'''Let us try out this initial version of blueprint function'',r' °
'show ''ÉFX FN''' 'ends ''BEGIN''' 'show ''CtoN╢''' 'ends ''END''' °
'''What was just illustrated is the usage of a blueprint function to'' °
' '''detect bugs un the defined function. This one is easy to fix'',r' °
'show ''ÉFX FD,Γ''''U╜Dµ»,W,'''''''' ''''''''''''''' °
'''And now before we try CtoN╢ again let us add description of the''' °
'''algorithm. How much description? We will try an excessive amount.'' °
,r' 'FT╜Γ''1 showfn ''''CtoN''''''' °
'FT╜FT,aq ''The character array is first analyzed for the number of co °
lumns''' °
'FT╜FT,aq ''Line [2] finds the number of rows and columns of the chara °
cter''' °
'FT╜FT,aq ''table. Line [3] returns a boolean vector showing all colum °
ns''' °
'FT╜FT,aq ''that are blank. Boolean vector T identifies blank columns. °
Can''' °
'FT╜FT,aq ''we use this vector to determine how many columns of number °
s there''' °
'FT╜FT,aq ''are in the table? Clearly any string of zeros defines a c °
olumn.''' °
'FT╜FT,aq ''So how do we count the number of such strings? One way wo °
uld be to''' °
'FT╜FT,aq ''reduce all such strings to a single digit. Line [4] does j °
ust that.''' °
'FT╜FT,Γ''''''Let us verify this expression on an example'''',r''' °
'FT╜FT,Γ''show ''''T╜1 1 0 0 0 0 1 0 0 0 1 1 1 1 0''''''' °
'FT╜FT,''show ''''É╜I╜(T⌠1╟T,1)/T'''''' ''show ''''+/~I''''''' °
'FT╜FT,aq ''Line [5] ravels the character array, executes it and then °
re-shapes it.''' °
'FT╜FT,aq ''That looks like it might work. D has the right shape now.' °
'' °
'FT╜FT,''do'' ''''''Here are some examples. We first generate characte °
r array C:''''''' °
'FT╜FT,Γ''show ''''DISPLAY C╜2 5µ'''''''' 2 -5-3 13''''''''''''''' °
'FT╜FT,Γ''''''And now we will apply CtoN to this array'''',r''' °
'FT╜FT,Γ''show ''''CtoN C'''' ''''C[1;2]╜'''''''' '''''''''''' ''''C'' °
'' ''''CtoN C''''''' °
'FT╜FT,Γ''show ''''CtoN É╜,C,'''''''' '''''''''''' ''''CtoN '''''''' °
''''''''''''''' 'show ''ÉFX FN,FT''' 'do' °
'''The new version of CtoN╢ can now be used to find other problems.'', °
r' '''Let us see how the blueprint function works now!'',r' °
'ends ''BEGIN''' 'show ''CtoN╢''' 'ends ''END''' °
'''Clearly there are problems with function CtoN:''' °
''' 1. It fails to deal with minus signs used to indicate negative num °
bers''' °
''' 2. It gives an error message when when the argument is a vector''' °
''' 3. It gives an error message when the argument is a vector of blan °
Xks''' 'endd' °
*(1997 7 18 13 8 27 360) °
FTEACH4 ÉFX 'TEACH4' 'Σ Another approach to CtoN' °
''' IS THERE A BETTER WAY?'',r' °
'''With all the shortcomings of function CtoN, major changes are calle °
d for.''' °
'''As these changes are made, the documentation function CtoN╢ should °
be''' °
'''updated and used to verify that the modified CtoN behaves as desire °
d.''' '''But we should also ask: Is there a better way?''' 'do' °
''' Have we selected the right approach to solve the problem? Is the' °
'' °
'''algorithm used in CtoN the best one? And what is meant by "best"?'' °
' °
'''Before we look for efficient (i.e. fast) solutions, we must also as °
k''' '''whether our approach leads to a general solution.'',r' °
''' We should be willing to forgo the quest for speed, and concentrat °
e on''' °
'''solving the problem in all of its likely complexities. One of the m °
ost''' °
'''difficult things to do is to give up an existing algorithm that too °
k so''' °
'''much development time, and start "from scratch" with a clean slate. °
'',r' °
''' Recall that function CtoN does not handle well tables containing' °
'' °
'''a minus sign, does not handle table entries with missing data, does °
''' °
'''not work with character vectors (as opposed to arrays), and does no °
t''' '''work with vectors containing only blanks.'',r' °
'''Let us consider a completely new approach'',r' °
'show ''FD╜''''U╜V CtoN W;B;D;E;T'''' ''''Σ Convert character W to num °
eric''''''' °
'show ''FD╜FD,Γ''''E╜''''''''Right argument is not a valid table'''''' °
''''''''' °
'show ''FD╜FD,Γ''''╕(0⌠ÉNC ''''''''V'''''''')/L0 ╪ V╜0''''''' °
'''Local variable E is set to contain a message to indicate invalid ta °
ble.''' °
'''This time we start by testing for the presence of left argument. If °
''' '''absent, we form the default (0)''' 'do' °
'show ''FD╜FD,Γ''''L0:B╜'''''''' ''''''''⌠W╜W,'''''''' ''''''''''''''' °
'''The boolean array B marking all positions of a blank in the array w °
ill''' °
'''again be used to identify the number of columns in the numeric tabl °
e.'',r' °
'show ''FD╜FD,Γ''''╕(1≥µµW)/L1 ╪ B╜δ≡B ╪ U╜(,(D╜µW)µB)Γ,W ╪ ╕L2''''''' °
'''If the argument is of rank 0 or 1, go to the next line. Else use''' °
'''partition to generate a nested list of all entries in the table.''' °
'do' 'show ''FD╜FD,Γ''''L1:U╜BΓ,W ╪ D╜µU ''''''' °
'show ''FD╜FD,Γ''''L2:B╜+/(B⌠1╟B,0)/B''''''' °
'''For rank 0 and 1 arrays, apply B to partition the data. Then on the °
''' '''next line (L2), get the number of columns in the table.''' 'do' °
'show ''FD╜FD,Γ''''U[(^/■'''''''' ''''''''=U)/∞µU]╜Γ«V''''''' °
'''Some of the entries may be blank. Fill these with the default value °
V.''' 'do' °
'show ''FD╜FD,Γ''''''''''''U╜0'''''''' ÉEA ''''''''U╜»■U'''''''''''''' °
' °
'''If the execute (») fails for even one table entry, set the result o °
f''' '''the attempt to convert the table to numeric to zero.''' 'do' °
'show ''FD╜FD,Γ''''╕(1=╧U)/L3 ╪ E ╪ ╕0''''''' °
'''If the rank of the result is 0 (meaning the table is blank or the'' °
' °
'''execute has failed on one or more entries), display message E and e °
xit.''' 'do' °
'show ''FD╜FD,Γ''''L3:╕((µεU)=⌡/B,²1╟D)/L4 ╪ U╜∞0 ╪ E ╪ ╕0''''''' °
'''If the number of values does not match the size of the array, then' °
'' °
'''also print message E and exit. (This could happen if some entries'' °
' '''evaluate to two or more numeric values.)''' 'do' °
'show ''FD╜FD,Γ''''L4:U╜((²1╟D),B)µU''''''' °
'''When all tests pass, return the properly reshaped table.''' °
X 'show ''ÉFX FD''' 'endd' °
*(1997 8 19 11 23 51 516) °
FTEACH5 ÉFX 'TEACH5;FD' 'Σ Describing algorithm in blueprint function' °
'╕((0=ÉNC ''FN'')doif ''''''Do TEACH3 first!'''''')/0' °
'''Having re-defined function CtoN, we should now re-write CtoN╢.''' °
'''We can salvage only the first 11 lines of the old version'',r' °
'show ''πFN╜11╞FN''' 'FD╜''do'' ''''''THE ALGORITHM OF CtoN'''',r''' °
'FD╜FD,Γ''''''Here is a listing of function CtoN'''',r''' °
'FD╜FD,Γ''show ''''1 showfn ''''''''CtoN''''''''''''''' °
'FD╜FD,aq ''If the left argument is not given, a default value of zero °
''' °
'FD╜FD,aq ''assigned to V in line [3]. Next, blanks are identified in' °
'' °
'FD╜FD,aq ''line [4] as before. The resulting pattern is replicated fo °
r''' °
'FD╜FD,aq ''all rows of the array and the ravelled array is partitione °
d''' °
'FD╜FD,aq ''into its tabular elements in line [5]. For scalars and vec °
tors''' °
'FD╜FD,aq ''partition is made in line [6]. The number of columns is ob °
tained''' °
'FD╜FD,aq ''in line [7] and blank entries are replaced by the default °
value''' 'FD╜FD,aq ''V in line [8].''' 'FD╜FD,Γ''do''' °
'FD╜FD,aq ''At this point each element of the nested vector should''' °
'FD╜FD,Γ''''''contain an expression that will evaluate to a single num °
ber.'''',r''' °
'FD╜FD,aq ''The next step is to evaluate each element of this nested'' °
' °
'FD╜FD,aq ''vector. If one or more entries fail this evaluation, a zer °
o''' °
'FD╜FD,aq ''is returned on line [9]. On line [10], if the execute has' °
'' °
'FD╜FD,aq ''failed, or the argument is a scalar, display E and exit. I °
f''' °
'FD╜FD,aq ''the numeric vector has the wrong length [11](i.e. one or m °
ore''' °
'FD╜FD,Γ''''''entries return two or more values), then also display E °
and exit.'''',r''' °
'FD╜FD,aq ''The numeric table is returned if all these tests are passe °
d''' 'FD╜FD,Γ''do''' 'FD╜FD,Γ''''''EXAMPLES:'''',r''' °
'FD╜FD,Γ''show ''''DISPLAY R╜«3 3µ∞9'''' ''''DISPLAY 10+CtoN R''''''' °
'FD╜FD,aq ''A character array containing numeric data is converted to °
a''' 'FD╜FD,aq ''numeric array.''' 'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''R╜2 6µ'''''''' 12 -5-13 13''''''''''''''' °
'FD╜FD,Γ''show ''''R'''' ''''CtoN R''''''' °
'FD╜FD,aq ''Negative numbers (with minus signs) are converted correctl °
y''' 'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''R[2;2]╜'''''''' '''''''''''' ''''R'''' ''''CtoN R'' °
''''' °
'FD╜FD,aq ''The conversion works even if the minus sign is not next''' °
'FD╜FD,aq ''to the numeric value''' 'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''R[1;2 3]╜'''''''' '''''''''''' ''''R[2;2]╜''''''''1 °
'''''''''''' ''''R''''''' °
'FD╜FD,aq ''By blanking out the entry in row 1, column 1, we form an'' °
' 'FD╜FD,aq ''incomplete table''' 'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''CtoN R'''' ''''.123 CtoN R''''''' °
'FD╜FD,aq ''Applying CtoN monadically the empty slot is assigned a''' °
'FD╜FD,aq ''value of zero. This can be modified using CtoN dyadically. °
''' 'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''CtoN É╜,R'''' ''''CtoN É╜,R,'''''''' '''''''''''''' °
' °
'FD╜FD,aq ''CtoN now works with vectors (but notice that -5-13 evaluat °
es''' 'FD╜FD,aq ''to 8 because this expression contains no blanks)''' °
'FD╜FD,Γ''do''' 'FD╜FD,Γ''show ''''CtoN '''''''' ''''''''''''''' °
'FD╜FD,aq ''And it produces the desired message with a blank vector''' °
'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''R[1;1 2 3]╜''''''''ONE'''''''''''' ''''R'''' ''''Ct °
oN R''''''' °
'FD╜FD,aq ''An undefined character string in the array produces an''' °
'FD╜FD,aq ''error message''' 'FD╜FD,Γ''do''' °
'FD╜FD,Γ''show ''''ONE╜1'''' ''''CtoN R''''''' °
'FD╜FD,aq ''But when the label is assigned a value, CtoN works.''' °
'''The blueprint function then displays function CtoN, and follows thi °
s''' '''by a step by step descrition of the new algorithm'',r' °
'''The next section describes the test cases that function CtoN must p °
ass.'',r' °
'''NOTE:(If during the development process any of these test cases fai °
l,''' °
''' corrections must be made to CtoN until it works properly. Thi °
s''' °
''' TESTING and CORRECTING phase may require several cycles.)''' °
'do' 'show ''FN╜FN,FD'' ''ÉFX FN''' °
'''And now we can try out the final version of blueprint function CtoN °
X╢.''' 'do' 'ends ''BEGIN''' 'show ''CtoN╢''' 'ends ''END''' 'endd' °
*(1997 8 19 11 24 31 440) °
FTIME ÉFX 'U╜V TIME W;T' °
'Σ Measure execution time of W repeated V times' °
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 8 19 11 26 31 448) °
XFaq ÉFX 'U╜aq W' 'U╜Γaddquote W' °
*(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' °
*(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,■''-- .. ''' °
XCdig 1 10 1234567890 °
*(1997 9 9 13 0 45 372) °
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 °
of''' '''these tutorials.'',r' ''' ACKNOWLEDGEMENTS'',r' °
''' In writing these tutorials, I am greatly indebted to Roy Sykes, wh °
ose''' °
'''excellent lectures increased my understanding of the language.''' °
'''Discussions with the late Harry Bertucelli clarified a number of''' °
'''concepts and caused me to change some improper terminology that was °
''' °
'''used in previous versions of these tutorials. Mr. Benjamin Archer'' °
' °
'''kindly checked out a nearly final version, bringing to my attention °
''' '''some ommisions, misspellings, and invalid terminology.'',r' °
X '''(PRESS ENTER to continue)''' °
*(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 9 9 12 50 14 444) °
Fendd ÉFX 'endd' 'Σ end of special feature' '20µ''²'' ╪ ╕(4<µÉLC)/0' °
X 'do' °
*(1997 8 19 11 20 26 404) °
Fends ÉFX 'ends V' 'Σ end of special feature' 'V,(20µ''²''),''SAMPLE''' °
X 'do' °
*(1997 8 19 11 12 31 392) °
Ferase ÉFX °
'erase;t;EXIT;GO;HELP;DISPLAY;BIND;REVIEW;RULE;TIME;DISCLAIMER' °
'Σ 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 27 13 47 41 608) °
Fevaldd ÉFX 'u╜evaldd w;c;n' 'Σ Evaluate direct definition' 'u╜0' °
'n╜(w∞''Σ'')-1' 'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w' °
'╕((1 label╞c)doif ''''''Invalid label'''''')/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 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 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 33 8 424) °
Fglobals ÉFX 'globals' 'Σ Initialize useful global variables' °
'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' °
'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890''' °
X 'r╜ÉAV[13+ÉIO]' 'q╜''''''''' °
*(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 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' °
XClc 1 26 abcdefghijklmnopqrstuvwxyz °
*(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 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 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' °
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 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 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 7 13 12 28 57 536) °
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+2)╟r' 'a,(3<µ2πc)/'' Σ'',3╟2πc' °
*(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 13 12 28 58 540) °
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' °
*(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 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' °
XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ °
*(1996 4 6 16 10 2 216) °
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' °