-
Notifications
You must be signed in to change notification settings - Fork 0
/
var.py
85 lines (73 loc) · 2.41 KB
/
var.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import math
import operator
import mathfuncs
import sysfuncs
stack = []
key = ''
#to stack indicates whether a number should go to the stack. if it is false it should not
tostack = True
curs_pos = 0
number = None
keyword = None
command = False
lastkey = None
recurs = False
recurscommand = None
conf_ansi = True
conf_sci_not = False
conf_decimal = True
conf_decimal_precision = 20
conf_prompt = '>'
conf_colour_reset = False
conf_colour_digit_stack_number = 'yellow'
conf_colour_digit_stack = 'green'
conf_colour_alpha = 'green'
conf_colour_inline_help = 'cyan'
sys_commands = []
SYS_COMMANDS = {
'\r':sysfuncs.newline,
'\b':sysfuncs.backspace,
'q':sysfuncs.leave,
';':sysfuncs.clear_line,
'@':sysfuncs.catch_recurs
}
ADV_OPERATORS = {
'+':operator.add,
'-':operator.sub,
'*':operator.mul,
'/':operator.div,
'^':math.pow,
'srt':math.sqrt,
'cos':math.cos,
'sin':math.sin,
'tan':math.tan,
'log':math.log,
'epow':math.exp,
'tlog':math.log10,
'!':math.factorial,
'rm':sysfuncs.delete_stack,
'#':sysfuncs.swap,
'nlog':math.log,
'ra':math.radians,
'deg':math.degrees,
'crt':mathfuncs.cube_root,
'help':sysfuncs.assist,
'man':sysfuncs.assist,
';':sysfuncs.clear_line,
'E':mathfuncs.sci_notation,
'$':mathfuncs.invert_sign,
'dp':mathfuncs.decimal_places,
'rnd':mathfuncs.rnd,
'ver':sysfuncs.display_version,
'&':mathfuncs.fract,
'ncr':mathfuncs.ncr,
'\'':sysfuncs.drop,
}
MATHS_CONSTANTS = {
'pi':math.pi,
'eu':math.e
}
operation_single = ['srt', 'cos', 'sin', 'tan', 'epow', 'tlog', '!', 'nlog', 'ra', 'deg', 'crt', '$', '&']
operation_double = ['^', 'log', 'E', 'dp', 'rnd', 'ncr', '+', '-', '*', '/']
operation_none = ['pi', 'eu']
operation_custom = ['rm', 'help', ';', 'man', 'ver', '#', '\'']