Universal string expression compiles the RMBAL V7.0 User Guide

xiaoxiao2021-04-10  549

Welcome to visit Forcal Mathematics Software Main Station, I want to send me a message in the 6TO23 station: 9CBS Blog Baidu Space Forcal.dll V7.0 User Guide Directory [Page]

1 Simple Example 2 Forcal Identifier 3 Expressions and Data 4 Contributation and Variable 5 Assignment Statement 6 Arithmetic Operator 7 Relational Operator and Logic Operator 8 Common Operator and Brand Operator 9 Operator and Priority 10 Function Overview 11 Function value call and address call 12 Use expressions as a function of the parameter 13 forcal expression full-definition 14 flow control 15 character data processing 16 About array 17 About recursive call 18 About recursive call 18 About modular compilation 19 secondary function 20 efficiency 21 Main Specifications

Text: 1 Simple Example [Back to Top] [Return to Directory] F (X, Y) = X Y; // Function Definition; 2 F [2,3] 5; // Simple Calculation; In this example, the semicolon represents an end of an expression, and the two backslash // The following representation indicates that this representation and annotation method will always be employed. In the first expression, a function f, parentheses (), x, y is the index of the function, the equal number is the function body, the portion of the portion, the function calculates and returns two parameters. with. The function f of the above defined is called in the second expression. Note that in the test program forcaltest, only the expression of the independent variable is calculated. Therefore, only the first expression is compiled, not calculated. 2 Forcal identifier [Back to top] [Return to Directory] In Forcal, an identifier can be used to represent an expression name, or a function of a function, or a variable, or a symbol constant. The identifier can consist of one or more characters, which can be started with any English letters or underscore, which can be connected to English letters, numbers, or underscores (Underline use can increase the readability of the identifier, such as first_name). In Forcal, uppercase is the same, count and count are two identical names. Some legal identifiers are given below: First Last Addr1 Top _OF_FILE Name23 _Temp A23E3 MYVAR 3 Expressions and Data [Back to Top] [Back to Directory] Expression is Forcal's Compile Unit, if there is no syntax error, compile, will be generated The code executed. Forcal expressions can be simple, such as only one number; Forcal expression can also be complex, for example, a complex program. The following is some examples of simple expressions: 2; 2 3; 2 sin (3) -ln [6]; you can give the expression a name, this is the advantage: the way you can call it in the future This name calls the expression. The name of the expression is an identifier and must be in the beginning of the expression. For example, the above three expressions can be defined as follows: a () = 2; b () = 2 3; c () = 2 sin (3) -ln [6]; the general form of expression definition is : Name (a, b) = {a = a 2, b = 10, A b} where Name is the name of the expression, can not be the same as other defined expressions, but can be default; if defined Expression name, after the expression name, you must follow a pair of parentheses (only small parentheses), used to define the own variable, the number of variables can be zero, or there may be any plurality of arguments, Separation between variables; if the self-variable is defined by small brackets, the small braces must be followed by the equal sign, the alignment of the alignment, the aliquot and the equal number after the start, the aliquot and the equal number can not be lackless province. The executable portion of the expression consists of multiple statements, and multiple statements are separated by commas, and the expression always returns the value of the last statement; the other curly brackets are not required, but after the flower brackets, the expression is easier to read. .

When defining an expression in this way, it is actually a function that can be used, which can be used in any expression (just named the function). For this reason, we often speak the expression. Functions, or expressions are a function, but it is not true. Here is an example of a function definition and use. F (x, y) = x y; // function definition; 2 f [2, 3] 5; // function call; the following is some legal expressions example: 2; // constant (no ginseng) Expression (function); () = 2; // constant (no argument) expression (function); A () = 2; // constant (no argument) expression (function), but defines the name of the function, This function can be called in other expressions; B (x) = 2; // has an argument expression (function); C (x, y) = x y; // has two independent expressions (Function); The type of expression and data of the expression, the Forcal expression has three types: integer expressions, real estimates, and complex expressions; correspondingly, three basic data types: integer, real And plural. For example: i: 2 3; // integer expression, in the test program forcaltest, integer expressions are in i: start; 2.2 3; // Real express, in Test Program Forcaltest, the default is a real expression ; C: 2 3i; // complex expression, in the test program forcaltest, the complex expression is started at C: start; the Forcal compiler is converted to an integer when compiling the expression, if it is There is a fractional portion to cut off; convert the data in the real expression into a real number; convert the data in the complex expression into a plural, if the number is I, indicating an imaginary number. In Forcal, the decimal representation is very flexible, and the zero or back zero in front of the decimal point, for example: 5.6, 5.,. 6 is a legal data representation. In Forcal, a scientific counting can also represent numbers, such as: 10.3E8, 2E-10, etc., where e represents the index portion of 10 as the bottom, but the index cannot be a decimal, for example: 3e5.6, 8.6e. -6.7 illegal. 4 constants and variables [Back to top] [Return to Directory] Constant refers to the fixed values ​​that do not need the program calculation. There are two types of numerical constants and symbols. Such as 100 is a numerical constant. In Forcal, a symbol constant can also be represented by an identifier, but the definition of symbol constants is related to the specific software, and the specific example cannot be given here. Variables refer to the amount of values ​​that can be changed when the program is running. There are three variables, local variables, and global variables, where arguments are used to deliver parameters to expressions. In the Forcal expression, the variable must be used first, in which the arguments and local variables can only be accessed by the expression of the variable, and the global variable can be accessed by all expressions.

The variable is defined in the beginning of the expression, the format is as follows: f (a, b: x, y: s, t) = {x = 1, y = 2, A B X Y S T} F is The name, A and B of the expression are independent variables, X and Y are local variables, S and T are global variables. Self-variables, local variables and global variables are separated by colons, and the three can be default. The following examples are exemplified by legal variables: f () = ... // does not use any variable, referred to as a non-array expression; f (::) = ... // No use Variables, non-array expressions; f (a, b) = ... // define two independent variables A and B; f (: x, y) = ... // definition Two local variables x and y; f (:: s, t) = ... // define two global variables S and T; F (A, B: X, Y) = ... ... // Define two arguments A and B, two local variables x and y; f (a, b :: s, t) = ... // define two independent variables a And B, two global variables S and T; F (: x, y: s, t) = ... // define two local variables x and y, two global variables S and T; variables Use of the following examples: f (a, b: x, y: s, t) = {a = 1, b = 2, x = 3, y = 4, s = 5, T = 6}; // Function definitions and variable assignment; A (A, B: X, Y: S, T) = a; // function definition; B (A, B: X, Y: S, T) = b; // function definition; X (a, b: x, y: s, t) = x; // function definition; y (a, b: x, y: s, t) = y; // function definition; s (A, B: X, Y: S, T) = S; // function definition; T (A, B: X, Y: S, T) = T; // function definition; f (11, 22); // function call, Perform variable assignment; A (11, 22); // function call, return value = 11; B (11, 22); // function call, return value = 22; x (11, 22); // function call, Return value = random value; y (11, 22); // function call, return value = random value; S (11, 22); // function call, return value = 5; T (11, 22); // Function call, return value = 6; 5 Assignment statement [Back to top] [Return to Directory] The role of assignment statement is to assign a value to a variable. In Forcal, the variable can be assigned with the equal sign. For example: f (x) = x = 5; // function definition, assign the value 5 to the variable x; f [2]; // function call, return value is 5; the above example is simple, but wait The part can be any complicated expression.

6 Arithmetic Operator [Back to Top] [Back to Directory] Forcal has seven arithmetic operators, namely: (plus or positive), - (minus or negative), * (multiply), / (divided), ^ Has passenger), (self-increment), - (self)). Operators *, / and ^ are double-purpose operators. Note that the number is multiplied by the variables, the multiplication should not be omitted; when the multiplication is performed, the number of bases should be non-negative; when the multiplication is performed in an integer expression, the integer will be converted to the double precision implementation, and finally Then transform the calculation results into an integer. When the operator , - is applied, it is a binary operator. When it is a positive and negative operation, it is a single operator. Operators , - is a single-purpose operator, which can only be used for variables. makes the value of the variable 1, if is before the variable, then the operator performs the addition operation before the program statement accesses the value, the operator is called "front self-amplifier operator"; if After the operator is placed, then the operator performs an additional operation after the program statement accesses the value, and the operator is called "rear self-increasing operator". - minimize the value of the variable, if the operator performs subtraction operation before the program statement accesses the value, at this time - the operator is called "front self-exit operator"; if After the operator is placed, the operator performs subtraction operation after the program statement accesses the value, and the operator is called "rear self-exit operator". For example: (: x) = x = 2, x; // return value is 3; (: x) = x = 2, x, x; // return value is 3; (: x) = X = 2, x ; // Return value of 2; (: x) = x = 2, x , x; // return value is 3; (: x) = x = 2, - x; // return value is 1; (: x) = x = 2, - x, x; // return value is 1; (: x) = x = 2, X-; // return value is 2; (: x) = x = 2, x -, x; // The return value is 1; if the self-incremental operator is used in the plural expression, only the real part of the complex is converted, and the ingredients remain unchanged. For example: c: (: x) = x = 2 3i, x; // return value is 3 3i; c: (: x) = x = 2 3i, - x; // return value is 1 3i; the priority of the single operator is higher than the priority of the binocular operator, and the priority of the post-single operator is higher than the priority of the front single operator. For the same priority, according to the priority order from left to right. Note: Unicapped operators - (negative) priorities are higher than the priority of binocular operators ^ (multiplication). For example: -2 ^ 2; // Return value is 4; - (2 ^ 2); // The return value is -4; the priority of the arithmetic operator is shown in Table 6-1.

In the table, the operator priority in the same line is the same, and the priority of operators in different lines is sequentially lowered. Table 6-1: Arithmetic Operators and Priority Operators Speech , - Rear Single Operators, Self-Advanced Operators , -, , - Front Single Operators, " , - "For the self-increasing ministries ^ Passenger *, / multiply, divided ,-plus, minus 7 relational operators and logical operators [Back to top] [Back to Directory] The relationship is two values The size is compared, returns a logical value. The logical value is only two: logical truth and logic. Use 0 to represent logic fake in Forcal, any other non-zero value indicates logic. For example: 3> 2; // Return logic true; 2> 3; // Return logic fake; there are 6 relationship operators:> (greater than),> = (greater than or equal), <(less than), <= (less than) Equal), == (equal to),! = (Not equal). The logic value between the logical values ​​is logical, and the results of logical operations are still a logical value. There are three logical operators: & (logic and), | (logic or),! (Logic is not). The truth table given by Table 7-1 can master these three operations. Table uses 1 representative logic, 0 represents logic fake. Table 7-1 Truth Table

PQP & QP | Q! P00001010111111010010 In Forcal, only the logical value is used to represent logical values, and there is no meaning of the logical value. So, if you use the relational operator or logical operator in the plural expression, only the columns of the column is used, and the complex ingredients have no effect on the result of the calculation; in the calculation result, only the recorded real part is meaningful. , The virtual part is meaningless, but its value is the virtual value of the first parameter participating in the operation. For example: C: 2 3i> 5 6i; // Return value is 0 3i; c:! (2 3i); // The return value is 0 3i; C: 2 3i == 2 6i; / / The return value is 1 3i; C: 2 3i! = 2 6i; // Return value is 0 3i; this regulation of Forcal makes it unable to use == ,! = Comparative comparison of two plots is equal or unequal. If two complexes are equal or unequal, they should be compared to the columns of the real part of the plurality, see the example below. C: (: a, b) = a = 2 3i, b = 2 3i, a == b & xy (a) == xy (b); // return value is 1 3i; C :(: a, b) = a = 2 3i, b = 2 5i, a == b & xy (a) == xy (b); // The return value is 0 3i; in the above example, XY (a) is one The complex function is used to exchange the real and imaginary part of the plurality A. The priority of the relationship operator and the logical operator is shown in Table 7-2. In the table, the operator priority in the same line is the same, and the priority of operators in different lines is sequentially lowered. Table 7-2 Relationship operator and logical operator and priority

Operators are clear! Logic is not>,> =, <, <=, ==,! = Relational operator & logic and | logical or 8 comma operator and parentheractary [Back to top] [Back to Directory] Expression If there is a plurality of statements, you can separate with a comma. Forcal will calculate each statement in order from left to right, and return the value of the last statement. You can also put multiple comma-separated statements in a parentheses, and Forcal will also calculate each statement in order from left to right and return the value of the last statement. For example: (: x) = x = 2, x = 5, x; // return value is 5; (: x) = {x = 2, x = 5, x}; // return value is 5; (:) X, Y) = {x = 2, y = 5, x = [x = x 1, y = y 1, x y], x}; // return value is 9; (: x, y) = {x = 2, y = 5, [x = x 1, y = y 1, x y]}; // Return value is 9; 9 operator and priority [Back to top] [Back to Directory ] The operators and priorities in Forcal are shown in Table 9-1. In the table, the operator priority in the same line is the same, and the priority of the operators in different rows is sequentially lowered. Table 9-1: Forcal operator and priority

Operators are clear (), [], {} Brand operator , - rear single operator (self-increased, self-reduced)!, , -, , - front single operator (Non-, positive, negative, self-increasing, self-reduction) ^ Arithmetic operator (multiplication) *, / arithmetic operator (multiply, divided) , - arithmetic operator (plus, minus)>,> =, <, <=, ==,! = Relational operator (greater than, greater than or equal, less than, less than or equal to, equal to) & logic and | logic or = assignment operator, comma operator Note In Forcal, usually operators cannot For example, for example! -2 is wrong, you should add parentheses to separate the individual operators, that is, you should write! (- 2). There is also a FORCAL operator not listed in Table 8-1: & (address of the variable). Take the address operator & only (by a comma-separated) separate variable, which does not have any relationship with other operators, so this operator is not listed in Table 8-1, which us will be detailed below Introduce. 10 Function Overview [Back to Top] [Return to Directory] Function is Forcal's constituent module, which is the most important feature of Forcal. A function that completes a specific function by passing parameters to it. The usual function has a name that can be used by calling the function name and transmitting parameters. All functions will return a function value. The typical function calling method is as follows: Function Name (parameter 1, parameter 2, ...) function can have zero or more parameters, but even if there is zero parameter, the braces after the function name cannot be default. When the function is called, the parameters must match. There are three functions that can be used in Forcal: first-class functions, secondary functions, and custom functions (expressions). One of the first-level functions is a single variable function, the calculation speed is fast; the secondary function section is a function of the system, and the software is software to improve performance expansion, and the function is very rich; the custom function is actually actually An expression, is defined by the user, but only the name-free custom function can be called by other expressions. In fact, Forcal has a number of factors, called process control functions, but for them, the meaning of functions is not obvious, but more is the meaning of process control, so we do not include them in the above classification . The Forcal function has three types, namely integer functions, real-numbered functions, respectively corresponds to the three expressions of Forcal. Forcal stipulates that the primary function and secondary function can only be applied in the same type of expression (but you can use the Calfun (...) function to indirectly call other types of secondary functions), and the custom function can be applied to any In the expression, Forcal will automatically use the call to the custom function. If the multiple-defined function is called in an integer or real expression, the number of parameters passed should be twice as the number of arguments of the complex custom function, that is, assignments to the real part of the multiple variable parameters. And only the value of the real part of the plurality of custom functions can be returned. If a custom function of an integer or a real number type is called in the complex expression, the parameter should be sent to the integer or real custom function when the parameter should be sent, and the function return value is only passed. Give the columns.

For example: C: a (x, y) = x y; // multiple-defined functions, there are two parameters; A (1, 2, 5, 6); // When calling the function A, pass four parameters B (x, y) = x y; // Real customization function, there are two parameters; C: B (1 2i, 5 6i); // When calling the function B, two parameters are still transmitted; When the first-level function is calculated in an integer expression, the integer is converted to the double precision implementation, and finally the operation result is converted into an integer. The first level function in Forcal is shown in Table 10-1. Table 10-1: First class function function type real function integer function plural function Description Strove function sin (x) sin (x) cosord function COS (X) COS (X) Positive Split function TAN (X) Anti-Strove Function ASIN (X) Anti-String Function ACOS (X) Anteriorctimeter ATAN (X) Square Root Function SQRT (X) SQRT (X) SQRT (X) Index Function EXP (X) Exp (X) Exp (X) Natural Logarithmic Funter LN (X) LN (x) ln (x) Common logarithmic function LG (X) LG (X) LG (X) Double Sinusoidal Function SINH (X) [Exp (X) -EXP (-x)] / 2 Double Strove Function COSH (X) [EXP (X) Exp (-X)] / 2 Double Division Function Tanh (x) [EXP (X) -EXP (-X)] / [EXP (X) Exp (-X) ] Adjust Function INT (X) INT (X) Crane Part Absolute Function ABS (X) ABS (X) ABS (X) Conjugate Function CON (X) Separation Switching Function XY (x) The real part is 0 function X0 (x) imaginary part is 0 function Y0 (x) 11 function transmission value call and address call [Back to top] [Return to Directory] Piped call is to copy variable values ​​to the modulated function In the formal parameter, the function changes when executed, does not affect the variables used when the call is called. An address call (also called a reference call) is in the form parameters of the address of the variable to the modulated function, and the function changes when executed, the change in the parameter affects the variables used when the call is called. Typically, Forcal is called by the value, unless you use the address operator & (also called the reference operator) to inform the Forcal compiler, you should use parameters in the address. In the use of operators &, & only use (separated by commas), alone, alone. As follows: A (x, y) = x = 2, y = 3; (: x, y) = x = 5, y = 6, a (x, y), x; // pass value call, x = 5; (: x, y) = x = 5, y = 6, a (x, y), y; // pass value call, y = 6; (: x, y) = x = 5, y = 6 , A (& X, Y), X; //, address call, x = 2; (: x, y) = x = 5, y = 6, A (x, & y), Y; // address call, Y = 3; 12 Use an expression as a function parameter [Back to top] [Back to "] When the function is called, sometimes the name of the name (ie, custom function name) as a function of the function, will express it. The name of the formula is a string (two double quotes "..." content is a string) pass to the function.

See the example below: f (x) = x 1; // Define a metal function; g (x) = sin [x] 0.8; // Define a dollar function; Simpintegrate (0, 2, 0.0001, "f") // will be able to build a grade points, and the function f is integrated from 0 to 2, the accuracy is 0.0001; Simpintegrate (1, 2, 0.0001, "g"); // will change the born one yuan points, the function g from 1 to 2, accuracy is 0.0001; 13 FORCAL expression full definition [Back to top] [Back to Directory] Here, we summarize the full definition of Forcal expressions to help users better understand forcal. In order to define the integrity, the previously described above is repeated. The complete definition of the Forcal expression is as follows: f (a, b: x, y: s, t) = {x = 1, y = 2, [x y, x * y], (xy), A B X Y S T} f is the name of the expression, must be on the beginning of the expression, the name must be an identifier. Give an expression, mainly, you can call this expression by this name. Expression can also be no name, but in this way, it will not be called in other expressions. In Forcal, the name of the general expression is unique, and cannot give two expressions (except for the name of the module, the definition of the module will be described later). If you define an expression name, you must follow a pair of parentheses after the expression name (you can only use small brackets), to define variables, the number of variables can be zero, or there may be any plurality of variables, The variable is separated by a comma or colon. Use the variables separated by colon, from going to the back of the argument, local variables, and global variables. In this example, A and B are arguments, X and Y are local variables, S and T are global variables. By variables, local variables and global variables and colon can be default. Even if the expression is not named, a pair of parentheses (only small brackets can only be used), at this time, parentheses must be at the beginning of the expression. If the variables are defined by small brackets, the small composition must be followed by the equal sign, the aliquot of the alignment, the aliquot and the equal number, and the equal number can be indispensable. The expression may not be defined in the expression, at this time, only the executable portion, the constant expression, or no inclusion is not called an expression. Expressible parts cannot be default. The executable portion of the expression consists of multiple statements, and multiple statements are separated by commas, and multiple statements can be placed in a parentheses. Three parentheses (), [], and {} can be used in the executable, parentheses must be used. In Forcal, parentheses are an operator, with a value, the value of the last statement in the parentheses. Expression always returns the value of the last statement (outermost parentheses). In addition, the outermost parentheses is not necessary, but if the expression is a comma-separated plurality of statements, after the outermost parentheses, the expression is easier to read.

When defining an expression in this way, it is actually a function that can be used, which can be used in any expression (just named the function). For this reason, we often speak the expression. Functions, or expressions are a function, but it is not true. The following is an example of legitimate expression definition: 2; // constant (no argument) expression (function); () = 2; // constant (no argument) expression (function); (::) = 2 ; // constant (no argument) expression (function); a () = 2; // constant (no argument) expression (function), but defines the function name, can call this function in other expressions; A (::) = 2; // Constant (no parametric) expression (function), but define the function name, can call this function in other expressions; B (x) = 2; // has an argument Expression (function); (x) = 23; // has an argument expression (function), but no function name, you cannot call this function in other expressions; f (a, b) = ... ... // Define two arguments A and B; f (: x, y) = ... // define two local variables x and y; f (:: s, t) = ... // Define two global variables S and T; F (A, B: X, Y) = ... // define two independent variables A and B, two local Variables x and y; f (a, b :: s, t) = ... // define two independent variables A and B, two global variables S and T; f (: x, y: s, t) = ... // Define two local variables x and y, two global variables S and T; 14 flow control [Back to top] [Back to Content] In force, expressions Each statement is generally performed sequentially. However, some functions can change the order of the statement execution, called the flow control function. 14.1 Immediate return Function Return (X) End calculation and return to the value of the expression immediately is x. 14.2 Judgment Function IF (X, Y1, Y2, ..., YN) When the value of the logical statement is true, the statements Y1, Y2, ..., Yn, otherwise, not executed Statements Y1, Y2, ..., YN. This function must have at least 2 arguments, where the first parameter is a logical statement. The return value of this function is meaningless.

14.3 Custom Segmentation Functions Which {Logistic Statement 1, Statement 1, Logistic Schedule 2, Statement 2, ..., Logical Statement N, Statement N, Default Statement}; Forcal From Going to Post-calculation and detecting a logical statement Value, when the logic is detected, calculate the statement corresponding to this logic and returns the value of the statement. If the logic is not detected, the value of the default statement is calculated as a return value. If there is no default statement It produces a run error. This function must have at least 2 arguments. For example, a segment function is defined in the formula: (x) = which {x> 0, 2 * x-1, x * x-1}; if the return value of the function is discarded, the function can be used as a selection calculation function. use. 14.4 WHILE loop function While loop is a "model" cycle, which is characterized by determining whether the conditions are established. When the condition is established, the cyclic body is executed, otherwise, "If the cycle is exited," the "Perform loop when the condition is established". The circulation of the "model" cycle may not be executed once. The format of the While loop function is as follows: While {x, y1, y2, ..., break (), ..., continue (), ..., yn}; where x is a logical sentence; Y1, Y2, .. Break (), ..., continue (), ... yn is a cyclic statement statement. When the value of x is true, the cyclic body statement is sequentially executed until the value of the X is exit loop when the value is false. When performing a BREAK () function, the WHILE loop is jumped, and the statement section behind the While loop is executed; when the Continue () function is executed, the start statement X returned to the While loop continues. In the cycle statement, there must be a statement that modifies the value of the logical statement x, so that the value of the X is false, exits the cycler, otherwise an infinite loop will result. This function must have at least 2 arguments, where the first parameter is a logical statement. The return value of this function is meaningless. The following is an example of a While loop: (: i, k) = {i = 0, k = 0, while {i <= 1000000, k = k i, i }, // When i <= 1000000, calculate K = k i, then i ; k}; 14.5 Until loop function UNTIL loop is "until" loop, the characteristics are: first execute the cyclic body, and then determine whether the conditions are established, when the condition is established, exit the cycler, otherwise Continue to perform a cyclic body, ie "performing loop until the condition is established." The circulation of the "until" cycle is executed at least once. The format of the Until cycle function is as follows: Until {x1, x2, ..., breaf (), ..., continue (), ..., y}; Until is the cyclic function determined by first. The cyclic body statement X1, X2, ..., Break (), ..., Continue (), ..., and then calculate the value of the logical statement y, until the value of Y is true.

When executed to the BREAK () function, the UNTIL loop is jumped out, performs the statement section behind the Until loop; when the Continue () function is executed, the start statement X1 returns to the Until cycle will continue. In the cyclic statement statement, there must be a statement that modifies the value of the logical speech y, so that the value of Y is true, exits the cycler, otherwise an infinite loop will result. This function must have at least 2 arguments, where the last parameter is a logical statement. The return value of this function is meaningless. The following is an example of a Until loop: (: i, k) = {i = 0, k = 0, unsil {k = k i, i , i> 1000000}, // calculate K = K I, I , When I> 1000000 is quit; k}; Note: (1) Break () and continue () are two non-refined functions, only in the While and Until two loop functions. (2) Forcal supports multithreading, in multi-threaded programs, if it is accidentally entered an infinite loop, you can exit through another thread. 15 Character Data Processing [Back to Top] [Return to Directory] In Forcal, define a string in two double quotes, ie "..." represents a string. In the Forcal string, you can also enter some special characters with a backslash transfi character, see Table 15-1. Table 15-1 Reverse stroke

// Reverse slope "/" / "Double Quotes" "" / nnn arbitrary characters, NNN is the 10-en-en-en-value value of the character ASCII code, the NNN must be three numbers, such as characters of the ASCII code 9, should be written / 009 In addition to the definitions defined in the table, Forcal does not define other essential characters ("/" and other characters are illegal). It can be seen that the backslash "/" and dual quotes "" "can only be input by escape character. For example: PrintStr (" string !!! "); // output strings with the PrintStr function, PrintStr is the test program Forcaltest's function; forcal is continuously stored in the same expression when compiling the expression, and each string is converted into an integer, the integer is the position of the first character of the string. Thus The difference between the difference between the two adjacent strings, the length of the length of the previous string. For example: (: i, j) = {i = "Hello forcal!", J = "end", PrintStr (i), ji }; // This function returns the length of the first string; you can identify any type of data value with a string, which is another major feature of the forcal division calculation. As mentioned above, the character string form expression The name can be transmitted to the function as a parameter. At this time, the string identifies an expression. For another, the string "AA" in the following statement identifies a real number array, "Str" identifies a one-dimensional character number: NewrealarRay (" AA ", 10); // Apply for a real number" AA "with the NewrealarRay function, the array length is 10; Newstr (" str ", 10); // Apply for a one-dimensional character number" aa "with the NewStr function 10; Note: One-dimensional character array is actually a string, but the string needs to be accessed with a dedicated function. These functions are not defined in Forcal. 16 About array [Back to top] [Back to Directory] In the expression, the array can be defined by the corresponding function, which can be accessed by any representation. Considering that not all software operate an array, Forcal only provides a function that defines the array, no deposit Take the function of the group, the function of the access array is provided by an application using an array. 16.1 Define a one-dimensional integer number of NewIntarray ("AA", M, X1, X2, ..., XN): Integer function This function can only be Direct use in an integer expression. This function defines a one-dimensional integer number of "AA", the array length is m, can store M integers, the X1, X2, ..., XN logs assign initial value, initial value The length of the array should be ignored less than or equal to the length of the array. The significance of the function return value is as follows: 0: The definition is successful. 1: This array already exists. 2: Memory allocation failed. 3: You cannot use an empty string as an array name. 4: This function requires at least 2 parameters. 5: You should use a string as an array name. 6: The array length m should be greater than or equal to 1.

16.2 Define a one-dimensional double-precision real number of NEWREAlataY ("AA", M, X1, X2, ..., XN): Real function This function can only be used directly in real expressions. This function defines a one-dimensional double-precision real number of "AA", the array length is m, can store M real numbers, the X1, X2, ..., XN logs assign the initial value, the initial value should be less than or equal to array The length, excess initial value will be ignored. The significance of this function return value is as follows: 0: Define success. 1: This array already exists. 2: Memory allocation failed. 3: You cannot use an empty string as an array name. 4: This function requires at least 2 parameters. 5: You should use a string as an array name. 6: The array length m should be greater than or equal to 1. 16.3 Define a one-dimensional double-precision plurality of NewcomPlexArray ("AA", M, X1, X2, ..., XN): The complex function This function can only be used directly in the plural expression. This function defines a one-dimensional double-precision plurality of "AA", the array length is m, can store M multiplex, available X1, X2, ..., XN logs to the initial value, the initial value should be less than or equal to array The length, excess initial value will be ignored. The significance of this function return value is as follows: 0: Define success. 1: This array already exists. 2: Memory allocation failed. 3: You cannot use an empty string as an array name. 4: This function requires at least 2 parameters. 5: You should use a string as an array name. 6: The array length m should be greater than or equal to 1. 16.4 Define a one-dimensional character array NewStr ("aa", m, "..."): This function can be used in any expression. This function defines a one-dimensional character array "AA", the array length is m, can store M-1 characters, available "..." to set the initial value, "..." should be less than or equal to array Length, excess characters will be ignored. The significance of this function return value is as follows: 0: Define success. 1: This array already exists. 2: Memory allocation failed. 3: You cannot use an empty string as an array name. 4: This function can only have 2 or 3 parameters. 5: You should use a string as an array name. 6: The array length m should be greater than or equal to 1. Note: One-dimensional character array is actually a string. Since the string always ends with the flag 0, the character array of the length is M-1 characters. 16.5 Release Array DeleteArray (Type, "Name"): This function can be used in any expression. Where TYPE represents the type of array, type = 7: one-dimensional integer array, TYPE = 8: One-dimensional digital group, type = 9: one-dimensional number, type = 10: One-dimensional character array; Name is a group name. The meaning of the return value is as follows: 0: The space that successfully released the array occupied. 1: You should use a string as an array name. 2: Array type illegal. 17 About recursive calls [Back to top] [Back to Directory] If a function calls yourself directly or indirectly, call the recursive call called function.

The recursive call of the Forcal support function. In order to use recursive in Forcal, you need to set the corresponding type of stack in the corresponding type of expression. Setting with SetInTackMax (n) in an integer expression, set with SetRealStackMax (n) in real expressions, and sets setcomplexstackmax (n) in complex expressions. Note that the value of n cannot be too big. When N is large, the function recursive call will not overflow forcal's stack, but the system stack overflows, which will cause the program to run, lose data (the author is not very good Solve this problem! I hope that friends can help solve, deeply grateful.). You don't need to set up a stack every running program. If the stack settings are appropriate, you can only set up a stack. Below is the simplest example of recursive: setRealStackMax (10000); // Setting the real stack to 10000; A () = a (); // Function A recursively call yourself, belongs to infinity recursive calls. Direct running the above expression will return a stack overflow run error. Although the stack of overflow Forcal does not interrupt the operation of the program, for the above program, no matter how large the stack is set, because the recursive definition of the function A is wrong. The recursive function should contain a control of the function that continues to call it itself or returned. If there is no such statement, the recursive function will use the memory space allocated to the stack, causing the stack overflow an error. Let's take an example of returning normal recursive call. SetRealStackMax (1000); // Setting the real stack to 1000; FACT (N) = Which {n <= 1, 1, n * fact (n-1)}; // Sub-class function FACT recursive implementation; Fact (3) ; // Calculate 3 !; FACT (5); // Calculate 5 !; FACT (10); // Calculate 10 !; Fact (100); // Calculate 100! Here is an example of a cross-recursive. SetRealStackMax (1000); // Setting the real stack to 1000; // In the following statement, calfor () is the function defined in the test program forcaltest, which can call the real custom function at runtime; A (x) = printstr [" A ... "], if (x <1, return [x]), Calfor [" B ", X-1]; // a (...) function is called in the function; B (x) = printstr ["b ..."], IF (x <1, return [x]), Calfor ["a", x-1]; // b (...) function is called A (...) function; A [10]; // Start recursive program; 18 About modular compilation [Back to top] [Back to Directory] Forcal supports modular compilation of expressions. Since the test program forcaltest is very simple, there is no modular compilation feature of Forcal, so it is only a brief introduction to modularization.

When compiling expressions with Forcal, you want to specify the module number, and the module number is identified by an integer. In Forcal, one module consists of one or more expressions. The module uses an integer identifier, the integer is negative, as long as the absolute value is equal, it belongs to the same module. The module name is typically represented by a positive integer. The module has two types, namely the main module (0 # module), and a normal module (module of other labels). In the same module, the module number is negative expression can only be accessed (ie, call) the expression of this module, and only the expression of this module can be accessed; the module number is positive expression, which can be accessed within the module. Expression, you can also access other modules (except for main modules) all module numbers are positive expressions. This specification of Forcal, an expression with a negative module number is invisible in other modules, and it has played a role of information protection. Forcal stipulates that the main module can access all modules in this module or all modules in other modules. Therefore, the main module is often used in the main program. 19 Secondary Functions [Back to Top] [Back Directory] In the following description, FCERR represents the run error code of the corresponding function. 19.1 Integer Level 2 Function 19.1.1, Maximum Function MAX (X1, X2, X3, ...): If FCERR = 1: No parameters. 19.1.2, minimum function MIN (x1, x2, x3, ...): If FCERR = 1: No parameters. 19.1.3, the remainder function mod (x, y): Seeks the remainder of X / Y. 19.1.4, Symbol Transfer Function SIGN (X, Y): The symbol of this function takes the Y's symbol, the absolute value of the value, if Y = 0 is not symbolically transmitted, returns the X value. 19.1.5, Positive Work Function DIM (X, Y): When X> Y is X-Y, otherwise returns 0. 19.1.6 Setting Integer Stack Maximum Number SetintStackMax (N): Before using the recursive function, you need to set a certain number of stacks first. Usually n's value cannot be too large. When N is large, the function recursive call does not overflow forcal's stack, but the system stack overflows, which will cause the program to run interrupt. This function returns the number of stacks that actually set. If FCERR = 1: Memory allocation failed. 19.1.7, call the secondary function Calfun (M, "AA", X1, X2, ..., XN): You can only call the real or complex secondary function, the integer secondary function can be called directly, no need to use function. M = 5 When calling the real number of secondary functions; M = 6 calls the complex secondary function. "AA" is the secondary function name to be called. X1, x2, ..., XN is the independent variable of the secondary function. If the complex secondary function is called, the transmitted auto-variable parameters should be twice as the number of complex secondary functions, respectively, respectively correspond to the real part of the multiple variables, and the function returns, only returns a number of times The value of the real part. If FCERR = 1: This function uses at least two parameters, or the parameter does not match; fCERR = 2: You should use a string to pass the secondary function name; FCERR = 3: Function type parameter M illegal; FCERR = 4: Can't find it Secondary function; FCERR = 5: Memory allocation failed.

19.2 Real Level 2 Function 19.2.1, Anteriorctimeter ATAN2 (X, Y): Ask x / y's positive cut value, the quadrant is determined by the symbol of X and Y. 19.2.2, maximum value function MAX (x1, x2, x3, ...): If FCERR = 1: No parameters. 19.2.3, minimum value function min (x1, x2, x3, ...): If FCERR = 1: No parameters. 19.2.4, the remainder function FMOD (X, Y): Seeks the remainder of X / Y. 19.2.5, Take a small number of partial functions modf (x): This function decomposes X into an integer and fractional portion, and returns the fractional portion. 19.2.6, Symbol Transfer Function SIGN (X, Y): The symbol of the function takes the Y's symbol, the absolute value of X, if y = 0 is not symbolically transmitted, returns the x value. 19.2.7, Positive Work Function DIM (X, Y): When X> Y, X-Y, otherwise returns 0. 19.2.8, enhancing Bosn 1 yuan points Simpintegrate (A, B, EPS, "F"): a is the lower limit of integral, B is the maximum intensity limit, and EPS is the integrated accuracy requirement, f is the product function. Example: a (x) = sin [x] 0.8; Simpintegrate (1, 2, 0.0001, "a"); if fCERR = 1: The specified expression does not exist; FCERR = 2: Expression is not compiled; FCERR = 3: The number of parameters does not match; 19.2.9, summary function SUM ("f", y1min, y1max, y2dy, y2min, y2max, y2dy, ...): f as a function; Y1min, Y1max, Y1DY is the first value, final value, and parameter increment of the first index [initial value 0], and push it according to the subkey. Example: f (x, y) = sin [x] 0.8-y; SUM ("f", 1, 2, 0.01, 2, 5, 0.1); FCERR = 1: The specified expression does not exist; FCERR = 2: The expression is not compiled; FCERR = 3: The number of parameters does not match; FCERR = 4: constant expressions, unqualified; FCERR = 5: Memory allocation failed; FCERR = 6: The argument parameters illegally. 19.2.10, the mesh function Pro ("F", Y1min, Y1max, Y1DY, Y2min, Y2max, Y2DY ...): Please refer to SUM () for retention. FCERR = 1: The specified expression does not exist; FCERR = 2: The expression is not compiled; FCERR = 3: the number of parameters does not match; fCERR = 4: constant expression, unable to seek; FCERR = 5: Memory allocation failed FCERR = 6: The self-variable parameters are illegal.

19.2.11, data summation function DataSum ("f", y11, y12, ..., y21, y22, ...): f as a function; Y11, Y12, ... ... for the first set of self-variable data, it is pushed. Examples: f (x, y) = x * Y; DataSum ["f", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // The return value is 190; The sub-f (x, y) = x * Y, the sum of the values ​​when 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, respectively, respectively. The value of F [1, 2] F [3, 4] F [5, 6] F [7, 8] F [9, 10] is required. If FCERR = 1: The specified expression does not exist; FCERR = 2: The expression is not compiled; FCERR = 3: The number of parameters does not match; FCERR = 4: constant expression, unqualified. 19.2.12, Data Striving Function DataPro ("F", Y11, Y12, ..., Y21, Y22, ...): See DataSum () for use. If FCERR = 1: The specified expression does not exist; FCERR = 2: The expression is not compiled; FCERR = 3: The number of parameters does not match; FCERR = 4: constant expression, cannot be remembered. 19.2.13, Setting Real Stack Maximum number setRealStackMax (N): Before using the recursive function, you need to set a certain number of stacks first. Usually n's value cannot be too large. When N is large, the function recursive call does not overflow forcal's stack, but the system stack overflows, which will cause the program to run interrupt. This function returns the number of stacks that actually set. If FCERR = 1: Memory allocation failed. 19.2.14, array data and functions DataArraysum ("f", nn, n1, n2, ...): This function is self-variable in array data, and is cumulative for a certain expression. F is a function, NN states that there is NN group data, N1, N2, ... to a plurality of arrays corresponding to the argument. If FCERR = 1: The specified expression does not exist; FCERR = 2: The expression is not compiled; FCERR = 3: the number of parameters does not match; FCERR = 4: constant expression, unqualified; FCERR = 5: Data group Number NN should be greater than 0; the length of an array length in the FCERR = 6: array n1, n2, ... is less than NN. NewrealarRay ["A", 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; NewrealarRay ["B", 10, 3, 3, 3, 3, 3, 3, 3 , 3, 3, 3]; FF (A, B, C) = A B C; DataArraysum ["FF", 10, "A", "B", "A"]; 19.2.15, call two Level Functions Calfun (M, "AA", X1, X2, ..., XN): You can only call integer or multiple secondary functions, and the second-level function can be called directly without using this function.

M = 4 Tune integer secondary function; M = 6 calls the complex secondary function. "AA" is the secondary function name to be called. X1, x2, ..., XN is the independent variable of the secondary function. If the complex secondary function is called, the transmitted auto-variable parameters should be twice as the number of complex secondary functions, respectively, respectively correspond to the real part of the multiple variables, and the function returns, only returns a number of times The value of the real part. If FCERR = 1: This function uses at least two parameters, or the parameter does not match; fCERR = 2: You should use a string to pass the secondary function name; FCERR = 3: Function type parameter M illegal; FCERR = 4: Can't find it Secondary function; FCERR = 5: Memory allocation failed. 19.3 Complex secondary functions 19.3.1, setting the maximum number of plural stacks SetComplexStackMax (N): Before using the recursive function, you need to set a certain number of stacks. Usually n's value cannot be too large. When N is large, the function recursive call does not overflow forcal's stack, but the system stack overflows, which will cause the program to run interrupt. This function returns the number of stacks that actually set. If FCERR = 1: Memory allocation failed. 19.3.2, call the secondary function Calfun (M, "AA", X1, X2, ..., XN): Call only the integer or real secondary function, the complex secondary function can be called directly, no need to use function. M = 4 Tune integer secondary function; M = 5 calls the real secondary function. "AA" is the secondary function name to be called. X1, X2, ..., XN is the independent variable of the secondary function, only the complex real part is transmitted to the independent variable. When the function returns, the real part is the value of the secondary function, the imaginary portion is 0. If FCERR = 1: This function uses at least two parameters, or the parameter does not match; fCERR = 2: You should use a string to pass the secondary function name; FCERR = 3: Function type parameter M illegal; FCERR = 4: Can't find it Secondary function; FCERR = 5: Memory allocation failed. 20 Efficiency [Back to Top] [Back Directory] The following improvement methods are improved in force. 1. Put the portions that can be calculated in the expression in parentheses. For example, it is necessary to write an expression: f (x, y) = x-5-7 y): f (x, y) = x- [5 7] y or f (x, y) = x [ 5-7] y. 2. Try to use the self-increased mining operator and -. For example, write i = i 1 into i form. 3, the speed of the Until cycle function is faster than the While loop function. 4. Try to avoid mutual calls between different types of expressions because type conversion takes time. Try to use the Calfun (...) function. 5, try to avoid using global variables.

21 Key Technical Indicators [Back to Top] [Back to Table] 1, Expression Maximum Length: 2G; 2, Number of Self Variables: Unlimited; Real representation: unlimited; mostly available complex expressions: unlimited; up to the integer expression: unlimited; 5, the number available in the expression: no limit; 6, custom external functions : Unlimited; 7, WHILE loop, Until cycle maximum cycle number: unlimited; 8, expression recursive call Maximum layer: limited by system stack and custom stack size, custom stack up to 2G; 9, up to Stored User Custom Data Type: About 32K; 10, Performing Speed: The first-level function speed is about 50% of FORTRAN (or C / C ) execution speed; other cases, speed is slightly dropped; 11, forcal.dll file Size: 136K; 12, memory requirements: depending on the operation of Forcal. Copyright © Forcal Mathematics Software 2002-2007, All rights reserved E-mail: forcal@sina.com QQ: 630715621 Recent Update:

January 10, 2007

转载请注明原文地址:https://www.9cbs.com/read-133429.html

New Post(0)