Transpiled version (7190L) is out of date.
1 | sclass AI_CalculationBot > AttractorBot { |
2 | bool greet = true; |
3 | |
4 | run { |
5 | if (greet) say("I can calculate things for you"); |
6 | } |
7 | |
8 | // CONFIG |
9 | |
10 | class CalcAttractor > Attractor { |
11 | S op; |
12 | L<Number> arguments; |
13 | |
14 | public bool matches(S s) { |
15 | LS l = regexpFirstGroups("(\\d+)\\s*[x*]\\s*(\\d+)", s); |
16 | if (l(l) == 2) |
17 | ret setOp(f mul, l); |
18 | |
19 | l = splitAtPlus(s); |
20 | if (l(l) > 1 && all isInteger(l)) |
21 | ret setOp(f plus, l); |
22 | |
23 | l = splitAtMinus(s); |
24 | if (l(l) > 1 && all isInteger(l)) |
25 | ret setOp(f minus, l); |
26 | |
27 | false; |
28 | } |
29 | |
30 | bool setOp(S op, LS args) { |
31 | this.op = op; |
32 | arguments = map bigint(args); |
33 | true; |
34 | } |
35 | |
36 | run { |
37 | say(str(foldl_noSeed(op, arguments))); |
38 | } |
39 | } |
40 | |
41 | *() { |
42 | standardAttractors(new CalcAttractor); |
43 | } |
44 | } |
Began life as a copy of #1023143
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023147 |
Snippet name: | AI_CalculationBot |
Eternal ID of this version: | #1023147/9 |
Text MD5: | 11157795338814b45bc8895a5c85454d |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-05-15 19:18:45 |
Source code size: | 869 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 335 / 836 |
Version history: | 8 change(s) |
Referenced in: | [show references] |