-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparseFunc.js
46 lines (46 loc) · 1.06 KB
/
parseFunc.js
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
function parseFunc(tree, op, i) {
if(tree[i+1] instanceof DGNum) {
switch(op) {
case "q":
tree.splice(i, 2, tree[i+1].sqrt());
return tree;
case "s":
tree.splice(i, 2, tree[i+1].sin());
return tree;
case "c":
tree.splice(i, 2, tree[i+1].cos());
return tree;
case "t":
tree.splice(i, 2, tree[i+1].tan());
return tree;
case "à":
tree.splice(i, 2, new DGNum(1).div(tree[i+1].sin()));
return tree;
case "á":
tree.splice(i, 2, new DGNum(1).div(tree[i+1].cos()));
return tree;
case "â":
tree.splice(i, 2, new DGNum(1).div(tree[i+1].tan()));
return tree;
case "!":
tree.splice(i, 2, tree[i+1].powGam());
return tree;
case "h":
tree.splice(i, 2, tree[i+1].ln());
return tree;
case "m":
tree.splice(i, 2, tree[i+1].log10());
return tree;
case "p":
tree.splice(i, 2, tree[i+1].isPrime());
return tree;
case "?":
tree.splice(i, 2, tree[i+1].sign());
return tree;
case "±":
tree.splice(i, 2, tree[i+1].toBool());
return tree;
}
}
return tree;
}