diff options
author | nea <romangraef@gmail.com> | 2022-07-05 12:24:19 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-07-05 12:24:19 +0200 |
commit | 5c2f9513f056f9074966f181683ef6b2c6e10791 (patch) | |
tree | 82ea94a76ece3f9cdbd5595dd067f9571ea1d3a7 | |
parent | 744bdab73327d0c33387e8b7545e47d88894fac8 (diff) | |
download | NotEnoughUpdates-5c2f9513f056f9074966f181683ef6b2c6e10791.tar.gz NotEnoughUpdates-5c2f9513f056f9074966f181683ef6b2c6e10791.tar.bz2 NotEnoughUpdates-5c2f9513f056f9074966f181683ef6b2c6e10791.zip |
Remove stuff
-rw-r--r-- | shunting.py | 49 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java | 1 |
2 files changed, 0 insertions, 50 deletions
diff --git a/shunting.py b/shunting.py deleted file mode 100644 index 22d79f11..00000000 --- a/shunting.py +++ /dev/null @@ -1,49 +0,0 @@ -precedence = { - '-': 0, - '+': 0, - '*': 1, - '/': 1, -} - - -def shunting(inss: [str]): - op = [] - out = [] - for ins in inss: - if str.isnumeric(ins): - list.append(out, ins) - elif len(ins) == 1 and ins in "+-*/": - p = precedence[ins] - while op: - l = op[len(op) - 1] - if l == "(": - break - pl = precedence[l] - if pl > p: - out.append(op.pop()) - else: - break - op.append(ins) - elif len(ins) == 1 and ins in "mkbt": - out.append(ins) - elif ins == "(": - op.append(ins) - elif ins == ")": - while True: - if not op: - raise "ILLEGAL PARENTHESIS" - l = op.pop() - if l == "(": - break - out.append(l) - else: - raise f"UNKNOWN OP {ins}" - while op: - l = op.pop() - if l == "(": - raise "ILLEGAL PARENTHESIS" - out.append(l) - return out - - -print(shunting("1 + 22 k * ( 3 + 4 ) k".split())) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java index eb1ba425..89befec7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Calculator.java @@ -154,7 +154,6 @@ public class Calculator { public static List<Token> shuntingYard(List<Token> toShunt) throws CalculatorException { // IT'S SHUNTING TIME // This is an implementation of the shunting yard algorithm - // Dear god, just thinking about dijkstra makes me wet and hard, such a fucking good mathematician Deque<Token> op = new ArrayDeque<>(); List<Token> out = new ArrayList<>(); |