From: Eric S. Raymond Date: Mon, 28 Jun 2004 18:17:10 +0000 (+0000) Subject: Index up to "PRINT Subroutine" (End of v). X-Git-Tag: 1.0~10 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=bd847315fc793c796023199a95c5767bed55d9e7;p=mad.git Index up to "PRINT Subroutine" (End of v). --- diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index 6243c3e..102542d 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -873,10 +873,11 @@ DIMENSION statement for Q in the program that calls on MAX. for a value.DIMENSION Statement For a second example consider the problem of repeatedly solving, -by Newton's method, of the equation f(x) - +by Newton's methodNewton's +Method , of the equation f(x) - ax + x = 0, taking a different value for a -each time but with the restriction that a ≥ 1. This method involves -the repeated evaluation of the formula +each time but with the restriction that a ≥ 1. This method +involves the repeated evaluation of the formula @@ -990,11 +991,12 @@ causes the function and iterative formula to be evaluated again if |f(x)| ≥ ε. Otherwise, (i.e., |f(x)| < ε), the next statement in sequence is executed. -The PRINT statement causes three numbers - the current -values of a, x and ε to be printed. The arrangement and form -of the numbers on the printed page are controlled by the -format description which is the value of the vector named -ALPHA.Format +The PRINT statementPRINT + Statement causes three numbers - the current + values of a, x and ε to be printed. The arrangement and form of + the numbers on the printed page are controlled by the format + description which is the value of the vector named + ALPHA.Format The TRANSFER statement following causes the statement labelled ST to be the next one performed. @@ -1034,10 +1036,12 @@ values of a, x, ε. The final example before the description of the language in Chapter II is a more general and more elaborate illustration of -Newton's method. Here, we consider the solution of the equation -x3 + ax2 + bx + -c = 0, starting with some input value for x0, -using the iterative formula: +Newton's method.Newton's +Method Here, we consider the solution of the +equation x3 + +ax2 + bx + c = 0, starting with some input +value for x0, using the iterative +formula: @@ -1257,8 +1261,9 @@ subscripts separated by commas and enclosed in parentheses. Thus the following are "single variables:": X51, ALPHA6, LAMBDA, GROSS, while the following are elements of arrays: BETA(C1, C2, 6), X15(Y, Z1), J(6), J(Z1 + 5 *Z2, 5). (See for the -description of subscripts.) Parentheses enclosing subscripts may not -be omitted. +description of subscripts.) +ParenthesesParentheses +enclosing subscripts may not be omitted. @@ -1282,6 +1287,8 @@ the additional cards. Function Name +Name + The name of a function consists of one to six letters or digits followed by a period "." which must be written. The first character of a function name must be a letter. If the function is @@ -1294,6 +1301,9 @@ and COS. (X) are values of functions. Arithmetic Operations + +Operations, Arithmetic + The following arithmetic operationsArithmetic Operations are available: @@ -1308,7 +1318,8 @@ both the minus sign and the dash are accepted.) Multiplication, written as "*", e.g. Z5*D. (Note that the "*" may not be omitted. It is illegal to write Z5D, since it would be impossible to distinguish such a product from the -variable Z5D.) +variable Z5D.)Multiplication + Division, written as "/"; e.g., Z5/D. If both Z5 and D are integers, the result is again an integer; e.g., the "fractional @@ -1323,9 +1334,9 @@ meaning (Z5)D, i.e., Z5 raised to the power D.Exponentiation Negation, written as "-", e.g., -ALOHA, meaning the -"negative of ALOHA." Thus -X.P.-.5 -means -(X-.5). - +"negative of ALOHA."Negation +Thus -X.P.-.5 means -(X-.5). @@ -1348,7 +1359,9 @@ values of functions are arithmetic expressions. individual or subscripted array variable, then the following are also arithmetic expressions: +E, -E, .ABS.E, E + F, E - F, E * F, E/F, E.P.F, and (E)..ABS. -Absolute Value +Absolute Value +.P. + The only arithmetic expressions are those arising in (a) and (b). @@ -1356,18 +1369,22 @@ E * F, E/F, E.P.F, and (E)..ABS. Boolean Operations + +Operations, Boolean + The following Boolean, or logical, operations Boolean Operations are available in the language (where M and P are boolean expressions): .NOT.M has the value 1B if and only if M has the value -0B. +0B..NOT. (M) has the same value as M. M.OR.P has the value 0B if and only if both M and P -have the value 0B. +have the value 0B..OR. + M.AND.P has the value 1B if and only if both M and P have the value 1B. @@ -1421,6 +1438,8 @@ M.THEN.P, and M.EQV.P. Parentheses Conventions +Parentheses + Parentheses are used in the same way as in ordinary algebra and logic to specify the order of the computation. Also, certain conventions are used to allow deletion of parentheses. @@ -1483,6 +1502,8 @@ otherwise indicated by parentheses. Mode of Expressions +Mode + The kind of arithmetic performed on a constant, variable or function value is determined by its mode. There are five modes in MAD; floating point, integer, Boolean, statement label, and function @@ -1786,6 +1807,8 @@ OR WHENEVER 1B or alternately the statement +Otherwise + OTHERWISE @@ -1905,8 +1928,9 @@ statement. Following the word OF appears the name of the iteration variable (in the illustration: V), which may be either an individual variable or -subscripted array variable of any mode. To the right of the "=" sign -may appear any number of expressions E1, +subscripted array variable of any mode. +Mode To the right of the "=" +sign may appear any number of expressions E1, ... Em. The modes of the E1 bear the same relationship to the mode of V as they would in the statement V = E1 (see @@ -1995,12 +2019,13 @@ value of V will be used for incrementing, testing, etc. (For the meaning of the statement INTEGER J,N see ). -(ii) A Newton's Method solution (Xk+1 = +(ii) A Newton's MethodNewton's +Method solution (Xk+1 = xk - f(xk)/f'(xk)) of the equation f(x) = cos x - x = 0 could be written as a single statement, -using the criterion "|f(x)| < ε and |xk - -xk+1| = +using the criterion "|f(x)| < ε and |xk +- xk+1| = |f(xk)/f'(xk)| < | ε" for stopping the iteration: @@ -2088,8 +2113,9 @@ iteration b is completed before iteration statements, they are said to be "nested". The "nesting depth" of an iteration statement is the number of iteration statements in whose scope it appears. The nesting depth of an iteration may not exceed -50. Depth, Nesting, of -Iteration For example: +50. Depth, Nesting, of Iteration +Nesting Depth of Iteration +For example: &scope4; @@ -2107,6 +2133,8 @@ statements in the scope of an iteration. Pause Statement +PAUSE Statement + PAUSE NO. n @@ -2340,7 +2368,8 @@ units (See Restrictions below). (a) PRINT FORMAT &scriptF;, &scriptL; Prints &scriptL; according to format &scriptF; on the off-line -printer. +printer.PRINT FORMAT Statement + @@ -2349,7 +2378,9 @@ printer. Prints &scriptL; according to format &scriptF; on the on-lin printer. This statement is used for comments to the operator. After &scriptL; has been printed a skip of 1/6 page is automatically -produced, allowing the operator to read the comment. +produced, allowing the operator to read the comment. +PRINT ON LINE FORMAT Statement + @@ -2810,8 +2841,9 @@ fields. A "scale factor" may be applied to an F number 10Scale factor (where the scaling is accomplished before the conversion is -done). The "scale factor", followed by the letter "P" is prefixed to -the basic field specification, as in the example +done). The "scale factor", followed by the letter +"P"P Prefix (Format) is +prefixed to the basic field specification, as in the example -2P2F7.3, F7.3* @@ -2836,6 +2868,8 @@ case. Multiple Specifications +Multiple Specifivcations (Format) + Several specifications may be condensed into one larger one by the use of the character "/". Each appearance of "/" (except as part of a Hollerith field-see ) @@ -2969,9 +3003,9 @@ specification 1H1, 2F11.3, S16, 3HM =I3, S9, 3HJ = 13*: 456.101 -1612.510 M = 50 J = 17 -As stated above, a specification may not account for more than 72 -columns on a card. It may happen, however, that a list calls for more -information than can appear on a single card. Or perhaps only a +As stated above, a specification may not account for more than +72 columns on a card. It may happen, however, that a list calls for +more information than can appear on a single card. Or perhaps only a certain part of each card is to be read. The determining factor in every case is whether or not the entire list has been accounted for. After each cards is read according to the format specification, the @@ -2983,10 +3017,12 @@ specification (the *) until it hits a left parenthesis not in an H field. (If there is no left parenthesis, it will move to the beginning of the specification). It then examines the characters just to the left of this left parenthesis to see if they are a multiplicity -indication (see ). From this left parenthesis (together -with the multiplicity, if any) to the end of the specification now -becomes the format specification until the list is satisfied. A -similar statement may be made for printed or punched output. +indication (see ). Multiplicity +From this left parenthesis (together with the multiplicity, if any) to +the end of the specification now becomes the format specification +until the list is satisfied. A similar statement may be made for +printed or punched output. Thus, in the specification: @@ -3056,6 +3092,7 @@ read and stored until needed. Declarations (Non-executable statements) Declarations +Non-Executable Statements Declarations are non-executable statements, and, except for function declarations, they may occur anywhere in the program. Their purpose @@ -3079,6 +3116,9 @@ column 11. unless declared otherwise. Any of the other modes may be specified as the normal mode by writing the following declarations: +Mode +Mode Declaration + NORMAL MODE IS &scriptM; @@ -3277,10 +3317,12 @@ EQUIVALENCE declaration, and any number of such declarations may occur (at any place) in a program. They will be treated as one combined declaration, however. -Variables whose names appear within the same set of parentheses need -not have the same mode. The mode must be established by the -appropriate MODE declaration for each of the variables. Occurrences -within an EQUIVALENCE declaration do not establish mode. +Variables whose names appear within the same set of parentheses +need not have the same mode. The mode must be established by the +appropriate MODE declaration +Mode for each of the +variables. Occurrences within an EQUIVALENCE declaration do not +establish mode. A nonsubscripted array variableArray Variables name in an EQUIVALENCE statement @@ -3381,6 +3423,8 @@ implement COMMON. Presetting Vectors +Presetting Vectors + Any vector or portion of a vector (or array when considered as a vector, i.e., using linear subscripts) may be preset by a declaration @@ -3445,10 +3489,12 @@ identical in all sections of the program. There are two main types of functions: The internal function and the external function. -EXTERNAL FUNCTION -Since these are quite similar in many ways, that part of the -description which is specific to external functions will be - +EXTERNAL FUNCTION Since +these are quite similar in many ways, that part of the description +which is specific to external functions will be + + + given in , that which is specific to internal functions in , and that which is common to both types will follow in subsection . Throughout this section a single-valued function will be called a "function", and a function with multiple outputs and/or multiple exits will be called a "procedure". For the purposes of this manual a recursive function is -one whose definition contains calls for the function being defined ⅆ -or calls for functions which ultimately call the one being defined. -Recursive functions have the same structure as other functions -although, in general, they will include statements of the type -described in , and certain +one whose definition contains calls for the function being defined +ⅆ or calls for functions which ultimately call the one being +defined. Recursive functions have the same structure as other +functions although, in general, they will include statements of the +type described in , and certain considerations should be borne in mind when constructing such -functions. These considerations arise from the fact that -names , instead of values, are used as function arguments. -The problem is considered in more detail in the examples in Chapter -III. +functions. These considerations arise from the fact that +namesName, +instead of values, are used as function arguments. The problem is +considered in more detail in the examples in Chapter III. External Function Definitions @@ -3483,15 +3529,16 @@ be translated indpendently of the main program in which they are to be used. (Because of this independence this block of statements is to be considered an entirely separate program, and must have its own DIMENSIONDIMENSION Statement -and MODE declaration, etc.) The word "EXTERNAL" also implies that -occurrences of variables and functions in the current function -definition program have no relation whatever with occurrences of -similarly named variables and functions in the main program (or other -definition programs), and no difficulties will be encountered because -of the use of similar names. The modes of the arguments (if other -than the normal mode), must be declared in the usual way (see ), but arraysArray -Variables which are arguments need not be +and MODE Mode declaration, +etc.) The word "EXTERNAL" also implies that occurrences of variables +and functions in the current function definition program have no +relation whatever with occurrences of similarly named variables and +functions in the main program (or other definition programs), and no +difficulties will be encountered because of the use of similar names. +The modes of the arguments (if other than the normal mode), must be +declared in the usual way (see ), +but arraysArray Variables +which are arguments need not be dimensioned.Arguments of Functions @@ -3507,19 +3554,18 @@ follows is to be translated as part of the main program. The word "INTERNAL" also implies that any variables or functions not listed as arguments in the definition of the - function (but used in its evaluation), are understood to be the same as elsewhere in the main program, and the current values of these variables and functions will be used. Names of variables and functions which occur as arguments of the function being defined are designated "dummy arguments" (or "bound variables")Bound Variables -Dummy Arguments. -They must be distinct from those appearing elsewhere in the program. -The modes of dummy arguments (if other than normal mode) must be -declared in the usual way, but arraysArray -Variables which are arguments need not be -dimensioned.DIMENSION +Dummy Arguments. They must +be distinct from those appearing elsewhere in the program. The +modesMode of dummy arguments +(if other than normal mode) must be declared in the usual way, but +arraysArray Variables which +are arguments need not be dimensioned.DIMENSION Statement One form of internal function definition (not available as an external @@ -3535,7 +3581,7 @@ INTERNAL FUNCTION SUMSQ.(X,Y,Z) = X * X + Y + Z * Z - T * T variables, and (X, Y, Z) is the dummy variableDummy Arguments list. The current value of T, however, will be obtained and used each -time the value of the function is needed. An example of theuse of +time the value of the function is needed. An example of the use of the function so defined would be: @@ -3547,6 +3593,7 @@ names of functions (without arguments) may appear in the dummy variable list. For this type of function definition no END OF FUNCTION statement is required. In the user of the function is an expression, the arguments may be any expressions that agree in mode +Mode with the corresponding argument in the declaration. In the example: @@ -3716,10 +3763,11 @@ Arguments in the declaration statement itself (statement A in the preceding paragraph) may contain only nonsubscripted variable names (either individual or array)Array Variables or -function names (without arguments). Within the definition program -itself (the statements between statement A and statement B), a -function name will usually occur with arguments, and an array variable -will usually occur with subscripts. +function names (without +arguments). Name Within the +definition program itself (the statements between statement A and +statement B), a function name will usually occur with arguments, and +an array variable will usually occur with subscripts. Function Definition @@ -3798,6 +3846,7 @@ in Chapter 4). COMMNT Subroutine ERROR Subroutine +PRINT Subroutine If a block designation @@ -3999,6 +4048,8 @@ that print as values in the table as Boolean, i.e., "0B" and "1B". This points up the fact that internally 0B and 1B are stored as 0 and 1, respectively. Also, the statement +NORMAL MODE IS Statement + NORMAL MODE IS BOOLEAN @@ -4507,6 +4558,8 @@ the integer mode, NAME is also declared to be integer. Example 2<emphasis role='note'>: Payroll Tape Processing</emphasis> +Payroll Example + Problem: Assume that a master tape is available containing basic information for each employee: (1) The employee number, (2) his hourly rate, (3) gross pay to date, (4) amount of withholding tax withheld to @@ -4607,6 +4660,8 @@ again. The Program: +NORMAL MODE IS Statement + &payrolltape; @@ -4619,6 +4674,8 @@ compile this example. The problem is the TAPE statement. Example 3<emphasis role='note'>: Mortgage Payment Processing</emphasis> +Mortgage Example + Problem: Mortgage Payment. The type of mortgage we consider is the fixed principle type for which each installment consists of an @@ -5167,7 +5224,10 @@ a call for this subroutine. PRINT Similar to TAPEWR above except that the use of tape 6 (the output tape) is implied. The PRINT FORMAT -... statement produces a call for this subroutine. +... statement PRINT FORMAT +Statement produces a call for this +subroutine.PRINT Subroutine + @@ -5202,7 +5262,8 @@ BCD informtion to be printed on the attached (on-line) printer. The arguments are the same as PRINT except that the line spacing is not given in the format specification since an automatic 1/6 page skip is produced. The statement producing the call is PRINT ON LINE -. . . . +. . . .PRINT ON LINE FORMAT Statement + @@ -6208,6 +6269,11 @@ example, if A is a 4 x 3 matrix (m = 4, n = 3) and b = 1, then V(1) = Labels, StatementStatement, Labels List, Input-OutputInput-Output List MatricesArray Variables +One-Dimensuiional ArrayVector +OR WHENEVER StatementConditional Statement +Parameters, SubroutineSubroutine Parameters +Precedence HierarchyParentheses +