Libraryless. Click here for Pure Java version (3873L/25K/87K).
1 | !752 |
2 | |
3 | !include #1004681 // Concepts |
4 | !include #1004924 // DB Classes |
5 | |
6 | p { |
7 | loadAndAutoSaveConcepts(); |
8 | print("Lines: " + l(conceptsOfType("Line"))); |
9 | makeBot("Boolean Flag Test."); |
10 | final L<S> exposedMethods = concatLists( |
11 | exposedDBMethods, |
12 | ll("xfindLine")); |
13 | makeBot("Boolean Flag DB.", new O { |
14 | S answer(S s) { |
15 | ret exposeMethods(s, exposedMethods); |
16 | } |
17 | }); |
18 | } |
19 | |
20 | static TheFlag getFlag() { |
21 | ret unary(TheFlag.class); |
22 | } |
23 | |
24 | synchronized answer { |
25 | TheFlag flag = getFlag(); |
26 | Line line = findWhere(list(Line.class), "text", s); |
27 | if (line == null) |
28 | line = new Line(s); |
29 | Interpretation ip = line.interpretation.get(); |
30 | if (ip == null) |
31 | ret "No interpretation for " + quote(s); |
32 | if (ip instanceof NotForMe) ret "Talk to the hand"; |
33 | if (ip instanceof GetFlag) ret yn(flag.set); |
34 | if (ip instanceof FlagOn) { |
35 | if (flag.set) ret "Flag already set!"; |
36 | flag.set = true; change(); |
37 | ret "OK, flag set."; |
38 | } |
39 | if (ip instanceof FlagOff) { |
40 | if (!flag.set) ret "Flag already cleared!"; |
41 | flag.set = false; change(); |
42 | ret "OK, flag cleared."; |
43 | } |
44 | } |
45 | |
46 | static PassRef xfindLine(S text) { |
47 | ret toPassRef(findWhere(list(Line.class), "text", text)); |
48 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004922 |
Snippet name: | Boolean Flag |
Eternal ID of this version: | #1004922/1 |
Text MD5: | bb449bb1bce5fd8fc402e748c49e797f |
Transpilation MD5: | a213ef0e28a54805217ee9891e7d730f |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-09-16 23:23:31 |
Source code size: | 1229 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 605 / 872 |
Referenced in: | [show references] |