d.ap ;.rm 70 .subtitle LANGUAGE ,.page .hl 1 ^&APL LANGUAGE\&  X This section is a short introduction to some of the concepts of the APL language. This section is meant to give the flavor of APL and introduce some of the concepts that were important in its implementation.  L This discussion may be slightly offensive to people who realy know APL for two reasons. .list x .le ;I am sure that it will gloss over some @less obvious points of APL either because I don't know them, or because they are not immediately important for getting a feel of the language.  l.le ;I will be using the SCI__APL ASCII and mnemonic forms of commands rather than the true APL forms because the production of the memo and 4slides would be too difficult, given my configuration, if I had to mix APL and ASCII characters. .end list ` The APL language has the following characteristics ( which are discussed in detail below: .list T .le ;DESK CALCULATOR mode .le ;LARGE NUMBER of primitive operators.  .le ;OPERATIONS between any dimension "square" data structures. .le ;INTERACTIVE programming language. .le ;SCI__APL help facilities. H .end list  It should be noted that in SCI__APL the alphabetic characters tthat are used in identifiers, system commands, and mnemonics are ALWAYS lower case. The upper case alphabetics are reserved for APL operators. <  In this section, user entries will be enclosed in double quotes, "...", hand optional entries enclosed in brackets, {...}.  0.page .hl 2 ^&DESK CALCULATOR mode\&  \ To begin with, once the user has entered the APL interpreter he can start to do calculations. This is done by entering immediate $statements, either an expression, or an assignment.   If an expression is entered, e.g. "2-3+5", then it is evaluated, Pand the result is displayed, e.g. __6. It should be noted that: 1) APL evalutate expressions from |right to left, with no operator precedent, thus 2-3+5 is evaluated as 2 - ( 3 + 5 ) and APL differentuates between the operator "-" and the Dnumeric sign "__".   If an assignment is entered, e.g. "x=3+4-5", then the expression is pevaluated, and the result is placed in the variable on the left of the assignment, e.g. x is set to 2. 8  The assignment, of course, permits the variable then to be used in a further expression, e.g. "x+x", results in displaying 4. In addition dthe assignment has a value, that can be tested, or used within the same line for further processing, e.g. "y = 100 + z = 10 - 2", sets z to 8 and then ,sets y to 108.   At any time, before exiting from APL via ")bye", the user can save his Xintermediate results via ")save {filename}". At a later time, he can restore these results via ")load {filename}".  .page .hl 2 ^&LARGE NUMBER of primitive operators\& L  APL provides tens of operations. These operations permit the use of one operation in many cases where the FORTRAN programmer might require a xset of statements. These operations differ depending on whether they are used as monadic operations or dyadic operations. For example: @  "2 X 3" .. is 6 .. In this case "X" is a dyadic operator, resulting  in the product of 2 times 3. l "X 3" .. is 1 .. In this case "X" is a monadic operator, resulting 4!in the signum of 3, i.e. +1 if the operand is greater than zero, 0 if the !operand is zero, and -1 if the operand is less than zero. ! `" This may be confusing to the non APL programmer, but it does allow "more operators than would otherwise be available. (# # The following table is a list of the APL operators. # T$.page $.lit % APL SYNTAX % ---------- % H&Number {__}{dddddd}{.dddddd}{e{__}dd} &Variable alpha{alpha/num...} {[subscript.exp]} 'Expression number .or. variable .or. ( expr ) .or. t' monadic.oper.or.fun expr .or. ' expr dyadic.oper.or.fun expr <( (Function def G function line {editing ...} e )System command ){system.command.name {parameters} h)Comment "..... ) 0* * SCALAR APL OPERATORS * -------------------- \+ +Oper Mnem Monadic Dyadic Comments $,---- ---- ------- ------ -------- , OP y x OP y , P-+ Identity Addition -- Negation Subtraction .X Signum Multiplication Monadic: +1, 0, -1 |.% Reciprical Division Monadic: 1 divided by y .* Exponential Exponent Monadic: e to power y D/ /A .an AND ..is.. MIN( x, y ) 0V .or OR ..is.. MAX( x, y ) p0T .nt NOT ..is.. .not. y .ge. fuzz 0 81< .lt Less..Than 1$ .le Less..Equal 2| .eq EQual d2_^ .ge Greater..Equal 2> .gt Greater..Than ,3 3S .mx Ceiling MAXimum Monadic: Integer above 3D .mn Floor MINimum Monadic: Integer below X4M ABS Val Residue Dyadic: mod( y, x ) 4 5O PI times Trig Functions Trig Fun: sin, cos ... 5O`* LOG LOG10 5'`. Factorial Combination ** not in SCI__APL L6Q Roll Deal Deal ** not in SCI__APL 6.end literal 7.page x7.lit 7 COMPLEX or VECTOR APL OPERATORS @8 ------------------------------- 8 9Oper Mnem Monadic Dyadic Comments l9 9 OP y x OP y 4: :I Index Gen Index of :R Dimension of Reshape `;, Ravel Concatenation ** concatenates ; to vectors (G`M .gd Grade down >B Base Value >N Representation H? ?/ Compression /`- or /[...] @_\ Expansion _/`- or _\[...] t@J.? Outer Product @?.? Inner Product