Libraryless. Click here for Pure Java version (7552L/51K/167K).
!7 concept Word { S text; long lastUsed; } p { db(); botSleep("Word Holder."); } synchronized answer { if (matchOneOf(s, "words", "list")) ret struct(wordsByLastUse()); if "size" ret str(countConcepts(Word)); if "add words *" { ret "OK, " + addWords(javaTokC($1)) + " new"; } } static L<S> wordsByLastUse() { ret collect(sortByFieldDesc(list(Word), "lastUsed"), "text"); } // return number of new words static int addWords(L<S> words) { long lastUsed = now(); int n = 0; for (S text : words) { Pair<Word, Bool> p = uniq2(Word, +text); if (p.b) ++n; cset(p.a, +lastUsed); } ret n; }
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: | #1008466 |
Snippet name: | Word Holder [OK] |
Eternal ID of this version: | #1008466/8 |
Text MD5: | e87232956cb063713ffdaa5b9d254091 |
Transpilation MD5: | b7f4f7115c46f6c2db8949af8fd5385e |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-16 15:20:26 |
Source code size: | 656 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 588 / 645 |
Version history: | 7 change(s) |
Referenced in: | -