home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
teachapl.zip
/
TEACH.ZIP
/
TEACH15A.ATF
< prev
next >
Wrap
Text File
|
1997-09-19
|
58KB
|
712 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 °
AANTE╜(('ONE')('TWO'))(('NOT TWO')('FOUR'))(Γ'THREE')(('FIVE')('NOT SIX °
X'))(('ONE')('THREE'))(('NOT TWO')('FIVE'))(Γ'ONE') °
*(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' °
XACONS╜('HERE')('THERE')('ONE')('FOUR')('SIX')('NOT SIX')('TWO') °
*(1997 9 14 12 30 44 504) °
XFDISCLAIMER ÉFX 'DISCLAIMER' 'Σ Copyright statement' 'disclaimer' °
*(1996 4 6 16 8 39 356) °
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 8 18 12 39 10 416) °
FEVALFRAME ÉFX 'U╜EVALFRAME W;F;N;R;T;P' 'Σ Evaluate frame W' °
'R╜1╞µF╜(FRAMEID∞ΓW)πFRAMES' '╕(1⌠µµF)/L0 ╪ U╜1╟F ╪ ╕0' °
'L0:N╜F[;1]∞''TEXT'' ''FUNC''' '╕(R<N[1])/L2 ╪ 1╟F[N[1];]' °
'L2:╕(R<N[2])/L3 ╪ »2πF[N[2];]' 'L3:╕(PεFRAMEID)/L4 ╪ U╜1 2╙F ╪ ╕0' °
X 'L4:EVALFRAME╞P' °
*(1997 8 18 12 38 53 584) °
FEVALRULE ÉFX 'U╜EVALRULE W;N;T' 'Σ Fire rule W' °
'ACT[W]╜0 ╪ N╜WπCONS ╪ É╜FACTS╜FACTS,ΓN' °
'╕(~T╜^/''NOT ''=4╞N)/L0 ╪ N╜4╟N' 'L0:╕T/L1 ╪ N╜''NOT '',N' °
X 'L1:╕(U╜~(ΓN)εFACTS)/0 ╪ ''Contradiction''' °
*(1996 4 6 16 8 39 356) °
FEXIT ÉFX 'EXIT' 'Σ Exit from function' '''To log off type: )OFF''' °
X '╕' °
XAFACTS╜('THREE')('NOT TWO')('ONE')('SIX')('TWO') °
XAFRAMEID╜('ROOT')('FIC1')('REAL') °
AFRAMES╜(4 4µ('NAME')('PERSON')(' ')(' ')('╞PTR')('ROOT')('FIC1') °
('REAL')('TEXT')('Is this person real or fictional?')(' ')(' ')(' °
FUNC')('P╜1 ''╞PTR'' GETVAL ''FICTIONAL'' ''REAL''')(' ')(' '))(( °
X'NAME')('Huckleberry Finn'))(('NAME')('Abraham Lincoln')) °
*(1997 8 18 12 39 13 428) °
FGETVAL ÉFX 'U╜V GETVAL W;X;P' 'Σ Extract contents of slot V given W' °
'æ╜P╜ε''Enter one:'',W,■'' ''' 'X╜(µP)╟æ' 'P╜(1πV)Φ1╟,F[F[;1]∞Γ2πV;]' °
X 'U╜P[W∞ΓX]' °
*(1996 4 6 16 8 39 356) °
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' °
XAGOALS╜('HERE')('THERE') °
*(1997 8 18 12 36 5 384) °
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 prompt 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╜6),'' 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' °
X '''REVIEW Review of previous lesson''' 'endd' °
*(1997 8 18 12 38 46 556) °
FINFEN ÉFX 'U╜INFEN;ACT;STACK;G;N;R;T' 'Σ Another inference engine' °
'ACT╜(N╜µANTE)µ1 ╪ STACK╜Γ∞0' 'L0:R╜(^/■(ACT/ANTE)ε■ΓFACTS)/(ACT/∞N)' °
'L2:╕(T╜1≥µR)/L3 ╪ PUSH(1╟R)ACT FACTS' °
'L3:╕(0=µR)/L1 ╪ ╕(EVALRULE╞R)/L6 ╪ ╕0' °
'L6:╕(δ/G╜FACTSεGOALS)/L4 ╪ ╕L0' 'L4:U╜G/FACTS ╪ ╕0' °
'L1:R╜,πPOP 1 ╪ ╕(0⌠╞R)/L5 ╪ ''Search failed'' ╪ ╕0' °
X 'L5:(R ACT FACTS)╜R ╪ ╕L2' °
*(1997 8 18 12 38 30 492) °
FPOP ÉFX 'U╜V POP W;T' 'Σ Remove W elements from STACK' °
'╕(0⌠ÉNC ''V'')/L0 ╪ U╜W╞πSTACK ╪ STACK╜ΓW╟πSTACK ╪ ╕0' °
X 'L0:U╜W╞T╜VπSTACK ╪ STACK[V]╜ΓW╟T' °
*(1997 8 18 12 38 27 480) °
FPUSH ÉFX 'V PUSH W;T' 'Σ Push W on top of STACK' °
'╕(0⌠ÉNC ''V'')/L0 ╪ STACK╜Γ(ΓW),πSTACK ╪ ╕0' °
X 'L0:STACK[V]╜Γ(ΓW),VπSTACK' °
XASTACK╜(1µΓ'ONE')(1µΓ'THREE') °
*(1997 9 2 12 30 56 504) °
FTEACH ÉFX 'TEACH' 'Σ Start lesson #15: APL2 by Zdenek V JIZBA' °
'exit ''TEACH''' 'initialize' °
'TEACH1 Σ The FIND primitive function; workspace 1 IDIOMS' °
'TEACH2 Σ The function MATCH' °
'TEACH3 Σ The "without" primitive function' °
'TEACH4 Σ Push down stack; functions PUSH and POP' °
'TEACH5 Σ A more general inference engine' °
X 'TEACH6 Σ hierarchical networks; Frames' 'problems' °
*(1997 9 2 12 49 4 372) °
FTEACH1 ÉFX 'TEACH1;A;N;C' 'Σ FIND, using workspace IDIOMS' °
'''In lesson 14 we learned how to TRAP expressions without causing''' °
'''interrupts. Testing whether an expression is executable does not''' °
'''solve all problems when dealing with character data. In this lesson °
''' °
'''we will study more APL2 primitive functions that support extensive' °
'' °
'''manipulation of data. To illustrate the kind of problems where thes °
e''' °
'''functions are vital, we will describe a variety of structures that' °
'' '''go under the label of KNOWLEDGE BASE.''' 'do' °
'''But first, let us introduce an APL2 primitive function called FIND. °
''' °
'''It is dyadic and uses the symbol ╤ (ÉAV[210]). The right argument i °
s''' °
'''an array to be searched for the ocurrence of the left argument. The °
''' °
'''function returns a boolean array of the same shape and rank as the °
right''' °
'''argument. A one in this array shows the start of the matching seque °
nce.'',r' 'show ''''''SI''''╤''''MISSISSIPPI'''''' ''3 4╤∞6''' °
'''Find can be applied to arrays of rank two or greater'',r' °
'show ''A╜4 4µ∞9'' ''A'' ''N╜2 2µ2 3 6 7'' ''N'' ''N╤A''' °
'''The matching pattern is identified by a 1 on the elements that have °
''' '''the smallest component values in the access vector'',r' °
'show ''(1 2)(3 3)╙■ΓA'' ''(1 2)(3 3)╙■ΓN╤A''' °
'''The rank of the left argument can be less than or equal to the rank °
''' '''of the right argument:'',r' °
'show ''C╜3 3µ''''ABCDE'''''' ''DISPLAY C'' ''''''DE''''╤C'' ''''''CD' °
'''╤C''' °
'''In the second example, the last C in row 1 cannot match, since the' °
'' '''elements of the left argument (CD) must be contiguous.''' 'do' °
'''Naturally, both the left and the right argument can be nested:'',r' °
'show ''N╜2 4µ1 ''''ONE'''' 2 ''''TWO'''' 3 ''''THREE'''''' ''DISPLAY °
N''' 'show ''DISPLAY (2 ''''TWO'''')╤N''' °
'''If the right argument is a large array, then we might desire to als °
o''' °
'''determine the access vectors of all ones in this boolean array. Sup °
pose''' '''we have the array'',r' °
'show ''A╜5 7µ∞9'' ''A'' ''N╜(É╜2 2µ2Φ∞4)╤A'' ''N''' °
'''There are two positions where the left argument matches array A: 1 °
3''' °
'''and 2 5. We need an algorithm to find these two access vectors.''' °
'do' '''We begin by generating the row and column indices'',r' °
'show ''DISPLAY ∞■µN''' °
'''Next we pair each of these row and column numbers using reduction.' °
'' °
'''since reduction produces a scalar, we extract the resulting array'' °
' '''with First'',r' 'show ''DISPLAY ╞°.,/∞■µN''' °
'''Finally to extract only those elements of N that contain a 1'',r' °
'show ''DISPLAY (,N)/,╞°.,/∞■µN''' °
'''The idiom displayed in the last expression is very useful in many'' °
' °
'''applications. It looks forbidding, but can be easily derived using' °
'' °
'''the three steps of our example. There may be times when you are in' °
'' °
'''a hurry to come up with a neat algorithm such as the one above, and °
''' °
'''do not wish to waste time developing it. There are publications''' °
'''that list a great number of idioms to solve most of the commonly''' °
'''ocurring problems. The IBM supplied library contains a special''' °
'''workspace to help you in this respect.''' 'do' °
'''For example, to retrieve the idiom just described here, do the''' °
'''following:'',r' ''' 1. Exit this lesson''' °
''' 2. Enter )LOAD 1 IDIOMS''' ''' 3. Enter IDIOMS''' °
''' 4. Specify BOOLEAN ARRAY as search argument''' °
''' 5. Look up Σ VECTOR OF POSITIONS OF ONE''''S IN BOOLEAN ARRAY''' °
'do' °
'''There are other alternate idioms to solve the same problem. Conside °
r''' '''for example the following one'',r' °
'show ''DISPLAY Γ[1](µN)ÿ(,N)/(2╙µN)+∞µ,N''' °
'''As an exercise try to analyze this expression. If the efficiency of °
''' °
'''an algorithm is related to the number of functions invoked, could t °
his''' '''algorithm be improved if it were defined as a function?''' °
X 'endd' °
*(1997 7 1 13 6 12 224) °
FTEACH2 ÉFX 'TEACH2;MATCH;FN;T;A;B;C' 'Σ Dyadic primitive MATCH' °
'''In lesson 7 we studied the monadic primitive called DEPTH. It has'' °
' °
'''the symbol ╧. There is also a dyadic version of ╧ called MATCH.'',r °
' °
'''In older versions of APL, testing whether two arrays are identical' °
'' '''is complex. Consider comparing two arrays A and C.'',r' °
'show ''C╜A╜2 2µ∞4 ╪ B╜2 2µ∞3 ╪ (2 2╙A)╜ΓC ╪ (2 2╙C)╜ΓB ╪ DISPLAY A C' °
'' °
'''First the rank must match, then the shape, and finally the elements °
.''' '''We could do it by defining function MATCH'',r' °
'show ''FN╜''''U╜V MATCH W;T'''' ''''Σ Return 1 only if V and W are id °
entical''''''' °
'show ''FN╜FN,Γ''''╕(~U╜(╧V)=T╜╧W)/0 ╪ ╕(~U╜(µµV)=µµW)/0 ╪ ╕(T>0)/L0'' °
''''' °
'''If the two arguments do not match in depth, return 0. Else if the'' °
' °
'''two arguments do not match in rank, return 0. Else if the rank is'' °
' '''not zero go to L0''' 'do' 'show ''FN╜FN,Γ''''U╜V=W ╪ ╕0''''''' °
'''If the rank is zero, use the = compare and exit'',r' °
'show ''FN╜FN,Γ''''L0:╕(~U╜^/(µV)=µW)/0 ╪ U╜^/(,V) MATCH■ ,W''''''' °
'''At L0, if the two arguments do not match in shape, return 0. Else a °
pply''' '''MATCH to each element of the two arrays.''' 'do' 'T╜ÉFX FN' °
'1 showfn ''MATCH''' 'do' 'show ''A MATCH C''' °
'''As function MATCH indicates, the process of matching two APL2 array °
s''' °
'''involves several steps. The dyadic version of ╧ handles it all.'',r °
' °
'show ''A╧C'' ''4╧''''4'''''' ''1 2 3╧∞3'' ''''''ABCD''''╧1Φ''''DABC'' °
'''' ''(2 2µ∞4)╧0 2°.+∞2''' °
'''The examples illustrate that match can be used to test whether APL2 °
''' °
'''expressions generate a desired result. It is this aspect of functio °
Xn''' '''match that makes it so useful in some applications.''' 'endd' °
*(1997 7 3 13 20 43 412) °
FTEACH3 ÉFX 'TEACH3;N;C' 'Σ Primitive dyadic WITHOUT (~)' °
'''There is another primitive monadic function that has an interesting °
''' °
'''dyadic version. In lesson 4 we learned that monadic NOT (represente °
d''' '''by ~) will reverse boolean values'',r' 'show ''~1 0''' °
'''The dyadic version of ~ is called WITHOUT. Unlike its monadic versi °
on''' °
'''which is restricted to boolean data, Without will work with all''' °
'''types of arrays. Without removes from the left rank 0 or 1 array''' °
'''argument all ocurrences of elements in the right argument'',r' °
'show ''(∞10)~2⌡∞10'' ''N╜∞6'' ''N~∞4'' ''N~0 1 0 1 0 1/N''' °
'''The shape of the right argument has no effect on this process'',r' °
'show ''''''ABCDEFG''''~''''ACEG'''''' ''''''ABCDEFG''''~2 2µ''''ACEG' °
'''''' °
'''Without works on elements of an array, even if they are nested'',r' °
'show ''''''ONE'''' ''''TWO'''' ''''THREE'''' ''''FOUR''''~''''ONE'''' °
''''TWO'''' ''''SIX''''''' °
'''The left argument should be a vector or a rank 0 array, but the rig °
ht''' '''argument is arbitrary.'',r' °
'show ''DISPLAY (Γ2 2µ∞4)~2 2µ∞4''' °
'''In the above example, the left argument is a rank 0 array, but the' °
'' °
'''right argument is treated as containing the scalars ∞4. Therefore t °
he''' '''left argument is left unchanged''' 'do' °
'show ''DISPLAY (,2 2µ∞4)~Γ2 2µ∞4''' °
'''In this example the left argument is equivalent to ∞4. The rank 0'' °
' '''right argument is not present there''' 'do' °
'''When all elements of the left argument are removed, "without" retur °
ns''' '''the prototype'',r' °
'show ''DISPLAY (Γ2 2µ∞4)~Γ2 2µ∞4'' ''DISPLAY (,2 2µ∞4)~2 2µ∞4''' °
'''Now explain the following result:'',r' °
X 'show ''DISPLAY 1 2 (2 2µ∞4)~2 2µ∞4''' 'endd' °
*(1997 7 3 14 7 28 304) °
FTEACH4 ÉFX 'TEACH4;FN;FN2;T' °
'Σ Using data structures; PUSH DOWN STACK' °
'''USING DATA STRUCTURES'',r' °
'''It is one thing to have powerful tools, but it is something else to °
''' °
'''be able to use them. In the remainder of this lesson we will sample °
''' °
'''some specific data structures, and define processes to use them.''' °
'do' °
'''We begin with the concept of a PUSH DOWN STACK. The concept is very °
''' °
'''similar to the physical device found in cafeterias. An empty plate' °
'' °
'''is handy to the customer in a device. As the top plate is removed,' °
'' °
'''a spring pushes the next empty plate into position for the next''' °
'''customer. We will now define two APL2 functions, PUSH and POP to''' °
'''simulate a generalized form of this activity. We will assume that'' °
' '''there is a global variable called STACK. We initialize STACK'',r' °
'show ''STACK╜Γ''''''''''' °
'''Function PUSH will enter data into this STACK. We will define PUSH' °
'' '''as a dyadic function, but we will delay dealing with the left''' °
'''argument for a while'',r' °
'FN╜''V PUSH W;T'' ''Σ Push W on top of STACK''' °
'FN╜FN,Γ''╕(0⌠ÉNC ''''V'''')/L0 ╪ STACK╜Γ(ΓW),πSTACK ╪ ╕0''' °
'T╜ÉFX FN,Γ''L0:ΣThis option to be developed later''' °
'1 showfn ''PUSH''' '''Let us see how this works'',r' °
'show ''DISPLAY STACK'' ''PUSH ''''ONE'''''' ''DISPLAY STACK'' ''PUSH °
''''TWO''''''' °
'show ''DISPLAY STACK'' ''PUSH ''''THREE'''''' ''DISPLAY STACK''' °
'''Each time PUSH is invoked, the right argument to PUSH is placed''' °
'''in front of the previous contents of STACK. To retrieve this stored °
''' °
'''information, we define function POP. This too will be dyadic, and'' °
' '''again we will postpone dealing with the left argument'',r' °
'FN2╜''U╜V POP W;T'' ''Σ Remove W elements from STACK''' °
'FN2╜FN2,Γ''╕(0⌠ÉNC ''''V'''')/L0 ╪ U╜W╞πSTACK ╪ STACK╜ΓW╟πSTACK ╪ ╕0' °
'' 'T╜ÉFX FN2,Γ''L0:ΣThis option to be developed later''' °
'1 showfn ''POP''' °
'''POP returns W items from STACK. At the same time it also removes th °
ese''' '''items from the stack'',r' °
'''Let us now remove two items from stack'',r' °
'show ''DISPLAY POP 2'' ''DISPLAY STACK''' °
'''Functions PUSH and POP as defined allow us to store temporary data' °
'' °
'''in an array called stack. Suppose now that we wish to store not''' °
'''one, but several stacks. This can be done by defining a left argume °
nt''' '''to PUSH and POP as an access vector'',r' °
'show ''STACK╜2µ'''''''' '''''''''' ''DISPLAY STACK''' °
'''We re-define push'',r' 'T╜ÉFX FN,Γ''L0:STACK[V]╜Γ(ΓW),VπSTACK''' °
'1 showfn ''PUSH''' °
'show ''1 PUSH ''''ONE'''''' ''2 PUSH ''''TWO'''''' ''1 PUSH ''''UNO'' °
'''' ''2 PUSH ''''DOS''''''' 'show ''DISPLAY STACK''' °
'''To retrieve selectively from this compound stack, we redefine POP'' °
,r' 'T╜ÉFX FN2,Γ''L0:U╜W╞T╜VπSTACK ╪ STACK[V]╜ΓW╟T''' °
'1 showfn ''POP''' 'do' '''And now we can extract from STACK'',r' °
'show ''DISPLAY 2 POP 2'' ''DISPLAY STACK'' ''2 PUSH ''''THREE''''''' °
X 'show ''DISPLAY 1 POP 1'' ''DISPLAY STACK''' 'endd' °
*(1997 7 7 12 41 20 416) °
FTEACH5 ÉFX 'TEACH5;FN;T' 'Σ Rule selection' °
'''When we described the game of Blackjack, we generated two nested''' °
'''arrays: ANTE and CONS. The simple inference engine of that game alw °
ays''' °
'''started with rule number 1. In more general Expert Systems, the rul °
e''' °
'''that is fired first is one that satisfies the conditions of ANTE. L °
et''' °
'''us assume that the elements of ANTE are CONJUNCTIONS. (To refresh y °
our''' '''memory, a conjunction is an expression of the form'',r' °
''' cond1 AND cond2 AND ...'',r' °
'''where expressions condx return a boolean value.)''' 'do' °
'''We will now develop a short application of such a general system. N °
ormally''' °
'''we would build a rule set consisting of phrases such as: "He has bl °
ue eyes"''' °
'''or "The person is heavy set". These phrases, called FACTS would be °
searched''' °
'''for in the antecedents of a rule set, and if found there, they woul °
d be used''' °
'''to generate new conclusions in the consequents of the rules. The co °
nclusions''' °
'''would then be incorporated into "new" FACTS. If a conclusion were o °
f a''' °
'''special type (such as "The person is George") called here GOALS, th °
en this''' '''result would be printed, and the search would stop.'',r' °
'''For simplicity, (and to make it easier to display an example) we wi °
ll''' °
'''replace phrases by short words (such as "ONE", "THERE" "NOT TWO"... °
). The''' '''concept, however should remain the same''' 'do' °
'''Here is an example of a ruleset'',r' °
'ANTE╜(''ONE'' ''TWO'')(''NOT TWO'' ''FOUR'')(Γ''THREE'')(''FIVE'' ''N °
OT SIX'')' °
'ANTE╜ANTE,(''ONE'' ''THREE'')(''NOT TWO'' ''FIVE'')(Γ''ONE'')' °
'CONS╜''HERE'' ''THERE'' ''ONE'' ''FOUR'' ''SIX'' ''NOT SIX'' ''TWO''' °
'DISPLAY ''RULE#'' ''ANTE'' ''CONS'',[0.1](7 1µ,■∞7)(πANTE)(7 1µCONS)' °
'do' '''We lso define a set of goals'',r' °
'show ''GOALS╜''''HERE'''' ''''THERE''''''' °
'''Suppose also that we begin the search with the following FACTS'',r' °
'show ''FACTS╜''''TWO'''' ''''THREE''''''' °
'''You can look at the rule set and find that by rule #3 fact ''''ONE' °
''' can''' °
'''be added to FACTS. Then by rule #5 we get ''''SIX'''', by rule #7 w °
e get''' °
'''''''TWO'''', and by rule #1 ''''HERE'''', which is a GOAL.''' 'do' °
'''In APL2, given the initial set of facts: ''''TWO'''' ''''THREE'''', °
we want to''' °
'''determine which of the seven rules is to be triggered'',r' °
'show ''(^/■ANTEε■ΓFACTS)/∞µANTE''' °
'''The above expression tells us which rule to fire first. Let us now' °
'' °
'''write an inference engine that will operate on this kind of problem °
.'',r' '''Since there are two steps involved'',r' °
''' 1. Find rules that can be fired''' ''' 2. Fire the rule'',r' °
'''We need two functions INFEN and EVALRULE.''' 'do' °
'''Now let us define function INFEN'',r' °
'show ''FN╜''''U╜INFEN;ACT;STACK;G;N;R;T'''' ''''Σ Another inference e °
ngine''''''' °
'''We are making INFEN niladic, since ANTE, CONS, FACTS and GOALS are' °
'' '''presumed to be global'',r' °
'show ''FN╜FN,Γ''''ACT╜(N╜µANTE)µ1 ╪ STACK╜Γ∞0''''''' °
'''We initialize two local variables. ACT is a vector of currently act °
ive''' °
'''rules. STACK is to store the state of the search to allow for a pro °
cess''' °
'''called BACKTRACKING. Note that we initialize STACK to return a nume °
ric''' '''null vector if empty'',r' °
'show ''FN╜FN,Γ''''L0:R╜(^/■(ACT/ANTE)ε■ΓFACTS)/(ACT/∞N)''''''' °
'''We apply the search algorithm, but we first reduce the ruleset to t °
he''' '''currently active rules.'',r' °
'show ''FN╜FN,Γ''''L2:╕(T╜1≥µR)/L3 ╪ PUSH (1╟R) ACT FACTS''''''' °
'''If more than one rule fires, save current status of knowledge, so i °
t''' °
'''can be restored in case the first rule leads to a dead end. This is °
''' '''called BACKTRACKING.'',r' °
'show ''FN╜FN,Γ''''L3:╕(0=µR)/L1 ╪ ╕(EVALRULE ╞R)/L6 ╪ ╕0''''''' °
'''If no rules fire begin the process of backtracking. Else evaluate'' °
' '''current rule. If it shows contradiction, do backtracking'',r' °
'show ''FN╜FN,Γ''''L6:╕(δ/G╜FACTSεGOALS)/L4 ╪ ╕L0''''''' °
'show ''FN╜FN,Γ''''L4: U╜G/FACTS ╪ ╕0''''''' °
'''If a goal shows up in the facts, return it and stop search. Else''' °
'''continue the search'',r' °
'show ''FN╜FN,Γ''''L1:R╜,πPOP 1 ╪ ╕(0⌠╞R)/L5 ╪ ''''''''Search failed'' °
'''''' ╪ ╕0''''''' °
'''To backtrack, POP previous status of search, and if the stack is em °
pty''' '''report failure'',r' °
'show ''FN╜FN,Γ''''L5:(R ACT FACTS)╜R ╪ ╕L2''''''' °
'''If stack is not empty, restore previously stored values of R, ACT'' °
' '''and FACTS''' 'T╜ÉFX FN' 'do' '1 showfn ''INFEN''' 'do' °
'''We will write a very simple rule evaluation function''' 'do' °
'show ''FN╜''''U╜EVALRULE W;N;T'''' ''''Σ Fire rule W''''''' °
'show ''FN╜FN,Γ''''ACT[W]╜0 ╪ N╜WπCONS ╪ É╜FACTS╜FACTS,ΓN''''''' °
'''First, make this rule inactive, then extract the consequent, add it °
''' °
'''to the list of FACTS and display FACTS to show how the process work °
s.''' 'do' °
'show ''FN╜FN,Γ''''╕(~T╜^/''''''''NOT ''''''''=4╞N)/L0 ╪ N╜4╟N''''''' °
'show ''FN╜FN,Γ''''L0:╕T/L1 ╪ N╜''''''''NOT '''''''',N''''''' °
'''Then, if the consequent begins with NOT, drop "NOT" from N; if it d °
oes''' °
'''not, add "NOT" to N so that a test can be made for contradiction''' °
'do' °
'show ''FN╜FN,Γ''''L1:╕(U╜~(ΓN)εFACTS)/0 ╪ ''''''''Contradiction'''''' °
''''''''' °
'''If the negation of consequent is in FACTS, enter "Contradiction"''' °
'''and return 0 (failure).'',r' 'T╜ÉFX FN' '1 showfn ''EVALRULE''' °
'do' '''Now let us see how it works'',r' °
'show ''FACTS╜''''THREE'''' ''''TEN'''''' ''INFEN'' ''FACTS╜''''NOT TW °
O'''' ''''FIVE''''''' °
'show ''INFEN'' ''FACTS╜''''THREE'''' ''''NOT TWO'''''' ''INFEN''' °
X 'endd' °
*(1997 7 7 13 28 42 456) °
FTEACH6 ÉFX 'TEACH6;T;FN' 'Σ Describe FRAMES' °
'''Another data structure that can be useful is called FRAME. When use °
d,''' °
'''a frame is just one component of a hierarchical network. When we''' °
'''define a frame structure, we must generate two nested vectors. (It °
may''' °
'''be possible to work with a single array, but things get a little mo °
re''' °
'''messy.) Let us call the two vectors FRAMES and FRAMEID. Vector FRAM °
ES''' °
'''contains the actual data structures, while vector FRAMEID is merely °
''' °
'''a list of unique POINTERS to each frame. Clearly the length of FRAM °
ES''' '''must be the same as the length of FRAMEID.''' 'do' °
'''Since FRAMES represents a hierarchy, we can always designate one of °
''' '''the frames as the ROOT frame'',r' °
'FRAMEID╜''ROOT'' ''FIC1'' ''REAL''' °
'T╜(''NAME'' ''PERSON'')(''╞PTR'' ''ROOT'' ''FIC1'' ''REAL'')' °
'T╜T,Γ''TEXT'' ''Is this person real or fictional?''' °
'T╜T,Γ''FUNC'' ''P╜1 ''''╞PTR'''' GETVAL ''''FICTIONAL'''' ''''REAL''' °
'''' °
'FRAMES╜(πT)(''NAME'' ''Huckleberry Finn'')(''NAME'' ''Abraham Lincoln °
'')' °
'show ''DISPLAY πFRAMEID'' ''DISPLAY (FRAMEID∞Γ''''ROOT'''')πFRAMES''' °
'''The root frame is an array. The elements in the first column are''' °
'''called SLOTS. For each slot, there is one or more VALUES. Values''' °
'''in general can be arrays, valid APL2 expressions, or pointers to''' °
'''other frames.''' 'do' °
'''In this particular illustration, we will adopt the following''' °
'''conventions:'',r' °
''' 1. Slots containing pointers are labels beginnimg with the symbol °
╞''' °
''' 2. If the values for a slot are pointers, then the first pointer'' °
' °
''' leads to the PREDECESOR frame. All subsequent pointers lead to' °
'' ''' SUCCESSOR frames''' °
''' 3. Frames that have no successors are called LEAVES.''' °
''' 4. Frames have rank 2, but leaves may have rank 1'',r' °
'show ''DISPLAY 1╟FRAMES''' °
'''In this example the remaining frames are leaves''' 'do' °
'''Now let us write function EVALFRAME to evaluate a frame structure.' °
',r' °
'show ''FN╜''''U╜EVALFRAME W;F;N;R;T;P'''' ''''Σ Evaluate frame W''''' °
'' 'show ''FN╜FN,Γ''''R╜1╞µF╜(FRAMEID∞ΓW)πFRAMES''''''' °
'show ''FN╜FN,Γ''''╕(1⌠µµF)/L0 ╪ U╜1╟F ╪ ╕0''''''' °
'''Retrieve the contents of the frame into local variable F. If F is'' °
' '''a vector, return the value''' 'do' °
'show ''FN╜FN,Γ''''L0:N╜F[;1]∞''''''''TEXT'''''''' ''''''''FUNC''''''' °
'''''''' 'show ''FN╜FN,Γ''''╕(R<N[1])/L2 ╪ 1╟F[N[1];]''''''' °
'''If the current frame has a slot labelled TEXT, display its value''' °
'do' 'show ''FN╜FN,Γ''''L2:╕(R<N[2])/L3 ╪ »2πF[N[2];]''''''' °
'''If the current frame has a slot labelled FUNC, evaluate the APL2''' °
'''expression (stored as value to slot FUNC). The result is assigned t °
o P.''' 'do' °
'show ''FN╜FN,Γ''''L3:╕(PεFRAMEID)/L4 ╪ U╜1 2╙F ╪ ╕0''''''' °
'''The local variable P contains the response to the inquiry made by G °
ETVAL.''' °
'''If P is not in FRAMEID, return row 1 col 2 of the FRAMES entry matc °
hing''' '''the original inquiry''' 'do' °
'show ''ÉFX FN,Γ''''L4:EVALFRAME ╞P''''''' °
'''Else evaluate the current frame'',r' '1 showfn ''EVALFRAME''' °
'''Function EVALFRAME is a bit simplistic, but it illustrates the type °
''' °
'''of processing that could be developed in frame based KNOWLEDGE.''' °
'do' °
'''Before we can test function EVALFRAME, we also have to define''' °
'''function GETVAL, which is invoked in slot FUNC.'',r' °
'show ''FN╜''''U╜V GETVAL W;X;P'''' ''''Σ Extract contents of slot V g °
iven W''''''' °
'''This function is made up to suit this particular example'',r' °
'show ''FN╜FN,''''æ╜P╜ε''''''''Enter one:'''''''',W,■'''''''' '''''''' °
'''' ''''X╜(µP)╟æ''''''' °
'show ''ÉFX FN,''''P╜(1πV)Φ1╟,F[F[;1]∞Γ2πV;]'''' ''''U╜P[W∞ΓX]''''''' °
'1 showfn ''GETVAL''' °
'''The last two expressions extract the contents associated with slot' °
'' °
'''given by V[2], and matched to the entries in W. If there is no matc °
h,''' °
'''the value returned is that of the first entry (the ROOT frame).''' °
'do' °
'''Let us see how this works. When asked to enter a choice, try first' °
'' '''an invalid response'',r' 'show ''EVALFRAME ''''ROOT''''''' °
'''As an exercise, consider defining function ADDFRAME. This function' °
'' '''should prompt you to add new frames and to update appropriate''' °
'''pointers in connecting frames. For example, use your ADDFRAME to''' °
'''insert one that would ask you whether REAL person is still living.' °
'' °
'''(Prompt for ''''DEAD'''' or ''''LIVING'''') Then point to either Ab °
Xe Lincoln''' '''or a living person of your choice.''' 'endd' °
*(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 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 18 12 34 4 372) °
Ferase ÉFX 'erase;t;EXIT;GO;HELP;DISPLAY;BIND;REVIEW;RULE;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 8 40 360) °
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' °