static synchronized S manageSnippetList(S s, S name, S varName) { L<S> list = (L) get(main.class, varName); new Matches m; if (match("list " + plural(name), s)) ret structure(list); if (match("how many " + plural(name), s)) ret str(l(list)); if (webAuthed() || litlist("yes", "partially").contains(isTrustedUser())) { if (match("add " + name + " *", s, m)) { S id = m.fsi(0); list.add(id); save(varName); ret "OK, " + name + " " + id + " added. List size now: " + l(list); } if (match("remove " + name + " *", s, m)) { S id = m.fsi(0); int idx = list.indexOf(id); if (idx < 0) ret id + " is not a " + name; list.remove(idx); save(varName); ret "OK, " + name + " " + id + " removed. List size now: " + l(list); } } ret null; }
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: | #1002457 |
| Snippet name: | manageSnippetList - convenient way of managing a list of snippets (e.g. "Turing tests") |
| Eternal ID of this version: | #1002457/1 |
| Text MD5: | 79758c8ec1bac2e470ec194228fe9904 |
| Author: | stefan |
| Category: | eleu |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-02-05 03:07:58 |
| Source code size: | 875 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 939 / 910 |
| Referenced in: | #1002628 - manageStringList - convenient way of managing a list of unchecked strings #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) |