1 | static S dumbCalc(S s) { |
2 | L<S> tok = javaTok(s); |
3 | int i; |
4 | BigInteger result = null; |
5 | for (S op : litlist("+", "-", "*", "/", "^")) { |
6 | while ((i = matchMetaNoStar(tok, "<number>", op, "<number>")) >= 0) { |
7 | BigInteger a = new BigInteger(tok.get(i)), b = new BigInteger(tok.get(i+4)); |
8 | result = mathOp(op, a, b); |
9 | clearAllTokens(tok.subList(i, i+5)); |
10 | tok.set(i, "" + result); |
11 | tok = javaTok(tok); |
12 | } |
13 | } |
14 | if (result != null) ret "" + result; |
15 | ret null; |
16 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003608 |
Snippet name: | dumbCalc - calculator with wrong precedence ^^ |
Eternal ID of this version: | #1003608/1 |
Text MD5: | 8573b890abc06ab0ef4e69e646282b48 |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-24 18:00:08 |
Source code size: | 504 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 529 / 542 |
Referenced in: | [show references] |