Libraryless. Click here for Pure Java version (7584L/50K/168K).
!7 concept TheList { S name; new L<S> entries; void add(S entry) { entries.add(entry); change(); } } concept Selection { TheList list; } static TheList list; p { dbIndexing(TheList, 'name); list = uniq(Selection).list; if (list == null) selectList("cool things"); if (isMainProgram()) botSleep(); } synchronized answer { if "select *" { selectList($1); ret "OK, has " + n(theList().entries, "entry"); } if "which" { ret list.name; } if "add *" { theList().add($1); theList().change(); ret "OK, has position " + l(theList().entries); } if "add * at *" { int i = parseInt($2)-1; theList().entries.add(i, $1); theList().change(); ret "OK"; } if "remove *" { int i = theList().entries.indexOf($1); if (i < 0) ret "Not in list"; else { theList().entries.remove(i); theList().change(); } ret "OK, removed from position " + (i+1); } if "length" ret lstr(theList().entries); if "entry *" { S entry = get(theList().entries, parseInt($1)-1); ret entry == null ? "Nuttn" : "Entry: " + quote(entry); } if "fix lol" { fixLOL(); ret "OK"; } } static TheList theList() { ret list; } svoid selectList(S name) { if (!hasConcept(TheList, +name)) { lol().add(name); lol().change(); } list = uniq(TheList, +name); cset(uniq(Selection), +list); } // the "list of lists" static TheList lol() { ret uniq(TheList, name := "lol"); } svoid fixLOL { lol().entries = collect(list(TheList), 'name); lol().change(); }
Began life as a copy of #1009225
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009226 |
Snippet name: | Core List Bot [should work] |
Eternal ID of this version: | #1009226/13 |
Text MD5: | fade12829c4b02fd799559757e8d5971 |
Transpilation MD5: | 484563b99a450e50dc028ca711a21f98 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-19 04:33:28 |
Source code size: | 1687 bytes / 94 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 414 / 543 |
Version history: | 12 change(s) |
Referenced in: | #1009228 - Core List Bot [formatted more compactly] |