Libraryless. Click here for Pure Java version (3873L/25K/87K).
!752 !include #1004681 // Concepts !include #1004924 // DB Classes p { loadAndAutoSaveConcepts(); print("Lines: " + l(conceptsOfType("Line"))); makeBot("Boolean Flag Test."); final L<S> exposedMethods = concatLists( exposedDBMethods, ll("xfindLine")); makeBot("Boolean Flag DB.", new O { S answer(S s) { ret exposeMethods(s, exposedMethods); } }); } static TheFlag getFlag() { ret unary(TheFlag.class); } synchronized answer { TheFlag flag = getFlag(); Line line = findWhere(list(Line.class), "text", s); if (line == null) line = new Line(s); Interpretation ip = line.interpretation.get(); if (ip == null) ret "No interpretation for " + quote(s); if (ip instanceof NotForMe) ret "Talk to the hand"; if (ip instanceof GetFlag) ret yn(flag.set); if (ip instanceof FlagOn) { if (flag.set) ret "Flag already set!"; flag.set = true; change(); ret "OK, flag set."; } if (ip instanceof FlagOff) { if (!flag.set) ret "Flag already cleared!"; flag.set = false; change(); ret "OK, flag cleared."; } } static PassRef xfindLine(S text) { ret toPassRef(findWhere(list(Line.class), "text", text)); }
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: | 603 / 868 |
Referenced in: | [show references] |