-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_definitions.py
More file actions
151 lines (119 loc) · 5.25 KB
/
function_definitions.py
File metadata and controls
151 lines (119 loc) · 5.25 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import library
function_definitions = []
unary_operations = []
binary_operations = []
boolean_operations = []
list_operations = []
compound_functions = []
class FunctionDefiner:
def __init__(self, identifiers, function, token_type, token_value):
self.identifiers = identifiers
self.function = function
self.type = token_type
self.value = token_value
def newUnaryFunction(identifiers, function, token_type, token_value = None):
new_function = FunctionDefiner(identifiers, function, token_type, token_value)
function_definitions.append(new_function)
unary_operations.append(token_type)
def newBinaryFunction(identifiers, function, token_type, token_value = None):
new_function = FunctionDefiner(identifiers, function, token_type, token_value)
function_definitions.append(new_function)
binary_operations.append(token_type)
def newBooleanFunction(identifiers, function, token_type, token_value = None):
new_function = FunctionDefiner(identifiers, function, token_type, token_value)
function_definitions.append(new_function)
boolean_operations.append(token_type)
def newListFunction(identifiers, function, token_type, token_value = None):
new_function = FunctionDefiner(identifiers, function, token_type, token_value)
function_definitions.append(new_function)
list_operations.append(token_type)
def newSpecialFunction(identifiers, function, token_type, token_value = None):
new_function = FunctionDefiner(identifiers, function, token_type, token_value)
function_definitions.append(new_function)
def newCompoundFunction(identifiers, function, token_type, token_value = None):
new_function = FunctionDefiner(identifiers, function, token_type, token_value)
compound_functions.append(token_type)
function_definitions.append(new_function)
####################
# Unary operations #
####################
# Reciprocal
newUnaryFunction(["~", "reci"], library.reci, "RECI")
# Factorial
newUnaryFunction(["fact", "factorial"], library.fact, "FACT")
# Trigonometric
newUnaryFunction(["sin"], library.sin, "SIN")
newUnaryFunction(["cos"], library.cos, "COS")
newUnaryFunction(["tan"], library.tan, "TAN")
newUnaryFunction(["cosec", "csc"], library.cosec, "COSEC")
newUnaryFunction(["sec"], library.sec, "SEC")
newUnaryFunction(["cot"], library.cot, "COT")
# Inverse trigonometric
newUnaryFunction(["arcsin", "sininv"], library.arcsin, "ARCSIN")
newUnaryFunction(["arccos", "cosinv"], library.arccos, "ARCCOS")
newUnaryFunction(["arctan", "taninv"], library.arctan, "ARCTAN")
# Hyperbolic
newUnaryFunction(["sinh"], library.sinh, "SINH")
newUnaryFunction(["cosh"], library.cosh, "COSH")
newUnaryFunction(["tanh"], library.tanh, "TANH")
# Roots
newUnaryFunction(["sqrt", "√"], library.sqrt, "SQRT")
newUnaryFunction(["cbrt", "∛"], library.cbrt, "CBRT")
# Logarithmic and exponential
newUnaryFunction(["ln", "log_e"], library.ln, "LN")
newUnaryFunction(["log", "log_10"], library.log, "LOG")
newUnaryFunction(["exp"], library.exp, "EXP")
# Step functions
newUnaryFunction(["floor", "gif"], library.floor, "FLOOR")
newUnaryFunction(["ceil", "ceiling"], library.ceil, "CEIL")
newUnaryFunction(["sign", "signum"], library.sign, "SIGN")
# Descriptive functions
newUnaryFunction(["abs", "magn"], library.abs, "ABS")
newUnaryFunction(["frac", "fractional"], library.frac, "FRAC")
# Internet functions
newUnaryFunction(["google"], library.google, "GOOGLE")
newUnaryFunction(["youtube"], library.youtube, "YOUTUBE")
#####################
# Binary operations #
#####################
# Basic Arithmetic
newBinaryFunction(["^", "power"], library.pow, "POW")
newBinaryFunction(["/", "by"], library.divide, "DIVIDE")
newBinaryFunction(["*", "times"], library.multiply, "MULTIPLY")
newBinaryFunction(["+", "plus", "and"], library.add, "ADD")
newBinaryFunction(["-", "minus"], library.subtract, "SUBTRACT")
newBinaryFunction(["%", "mod"], library.mod, "MOD")
# Combinatorics
newBinaryFunction(["P", "permutes"], library.perm, "PERM")
newBinaryFunction(["C", "choose"], library.comb, "COMB")
######################
# Boolean operations #
######################
newBinaryFunction(["<="], library.lte, "LTE")
newBinaryFunction([">="], library.lte, "GTE")
newBinaryFunction(["<"], library.lesser, "LESSER")
newBinaryFunction([">"], library.greater, "GREATER")
newBinaryFunction(["equals"], library.equals, "EQUALS")
##################
# List functions #
##################
newListFunction(["mean", "avg", "average"], library.mean, "MEAN")
newListFunction(["sd", "std_dev"], library.sd, "SD")
newListFunction(["variance"], library.variance, "VARIANCE")
newListFunction(["lcm"], library.lcm, "LCM")
newListFunction(["gcd", "hcf"], library.gcd, "GCD")
#####################
# Special functions #
#####################
newSpecialFunction(["print", "say", "display"], None, "PRINT")
newSpecialFunction(["=", "isEqualTo", "is", "are"], None, "ASSIGN")
######################
# Compound functions #
######################
newCompoundFunction(["increment"], None, "INCREMENT")
newCompoundFunction(["decrement"], None, "DECREMENT")
newCompoundFunction(["increase"], None, "INCREASE")
newCompoundFunction(["decrease"], None, "DECREASE")
newCompoundFunction(["append"], None, "APPEND")
newCompoundFunction(["prepend"], None, "PREPEND")
newCompoundFunction(["insert"], None, "INSERT")