"APP" Expression Calculator description document

Source: Internet
Author: User

Expression Evaluator Description Document
Expressionrunner

Download Link: http://pan.baidu.com/s/1sjlp6Zb

Main implementation Features:
1, the calculation of the basic expression, the realization of subtraction and parenthesized operation
2, the implementation of their own add variables, and you can add the variables to participate in the operation
3, add 5 default variables, pi pi, natural logarithm exp, infinity inf, non-number (not a digit) Nan, and the result of the last operation ans
4, you can let the INF and Nan participate in the operation, but will prompt the warning and return the corresponding value
5. Added 6 commands for custom variables, which are all display ls, display a variable cat, copy the variable CP, delete the variable mv, rename the variable rm, clear all the self-built variable CLS

Usage:
1. Expression Calculation part:
A) The style of the expression is as much as possible with the expression style in the common programming language;
b) Enter a valid expression (even a data can) will automatically calculate and display the result;
c) currently only supports 5 operators: Plus +, minus-, multiply *, divide/, and exponentiation ^;
d) allow parentheses to operate, but parentheses are still used only when nesting parentheses ();
e) allow a custom variable operation, such as input "PI * 2 * 2", will be considered a legal expression and calculated;
f) Use the assignment operator: = (Salute to the classic Pascal!) is the main new way of adding variables, the specific use is that the operator to the left is the newly added variable name, the right is an expression, the system will calculate the value of the expression, and then assign to the new variable;
g) do not allow nesting of new variables, such as "a:=a+1", because the system does not currently have a variable named A;
h) allow itself to re-assign values, such as "a:=a+1", if the implementation defines a value, the system will be calculated correctly;
2. Custom Variables section:
A) Clear the custom variable command CLS
I. Syntax: CLS
II. Direct input, the system will delete all the user's custom variables
Iii. 4 reserved variables (not including ANS) that are included as system will be retained
b) Check all variable command ls
I. Syntax: LS
II. Direct input, all variables will be printed on the screen
c) Check the single variable command cat
I. Grammar: Cat <Name>
II. After the input, the system will query the variable named <Name>, if any, print to the screen
III. For some variables with simple names, you can enter the name of the variable directly, and the value will also be displayed.
d) Copy a variable command CP
I. Grammar: CP <Name1> <Name2>
II. After input, the system assigns the value of <Name1> (if present) to the <Name2>
III. If a variable named <Name2> already exists, it will cause the modification to fail
e) Delete a variable command mv
I. Grammar: MV <Name>
II. After the input, the system will query the variable named <Name>, if any, delete the
III. The command can also delete system reserved variables
f) Rename a variable command rm
I. Syntax: RM <Name1> <Name2>
II. After input, the system will change the name of the variable named <Name1> to <Name2>
III. If a variable named <Name2> already exists, it will cause the modification to fail
g) Precautions
I. Although in fact, these commands are equivalent to the system reserved word, is not allowed as a variable to use, but in fact, there is a special use of the technique, that is, the CP Copy command to a variable with a special variable name of the assignment and calculation. If you need to evaluate it as a variable, place it at the back of the expression as much as possible, and do not make the expression and command-line commands ambiguous. The input is a legitimate attempt:


>>> 5 + 1
5 + 1 = 6
>>> CP Ans CP
>>> Cat CP
CP = 6
>>> 5 + CP
5 + CP = 11
>>>
Ii. A variable name is named with a string that contains only numbers and uppercase and lowercase letters for the first letter. That is, some simple variables and their participating operations:


>>> A1: = 2
>>> A2: = 3
>>> A1 + A2
A1 + A2 = 6
>>>
3. Global operation:
A) Close command exit
I. Syntax: Exit
II. Direct input, then close the program
b) You can also close the program by entering the EOF flag (CTRL + Z or F6 key in the keyboard)

Common errors:
1, forget to enter the following brackets: (1+5* (2+3)
2. The operator entered the error: 2%5
3. Forget to enter the colon for the assignment operator: sum=1+2+3+4+5
4, the command followed by too many parameters: CP avg sum solved.
5, other error commands and so on.

If you have a better suggestion, or found a bug, please contact me [email protected]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.