Libraryless. Click here for Pure Java version (2197L/15K/48K).
!759 !include #1002412 // Turing static void tests() { pcall { questions(); } } static void questions() { // load from bot //L list = cast call(getBot("#1002462"), "getLiveList"); // load from file L list = unnull((L) loadForeignVariable("#1002462", "questions")); L vals = unnull((L) loadForeignVariable("#1002462", "vals")); vals = slackUsersOnly(vals); Map<S, O> valsByID = indexByField(vals, "id"); prot("Found " + n(l(list), "question") + "."); // no shuffling for now, so latest questions show up top in "last dialogs" //list = shuffled(list); for (O tq : list) try { S id = getString(tq, "id"); S q = getString(tq, "question"); S a = getString(tq, "answer"); O _level = getOpt(tq, "level"); int level = (int) max(1, _level == null ? 1L : (long) _level); if (valsByID.containsKey(id)) prot("Skipping invalidated question: " + q + " => " + a); else add(q, a); } catch (Throwable e) { prot(str(e)); } } // TODO: .text static O loadForeignVariable(S progID, S varName) { S s = loadTextFile(getProgramFile(progID, varName + ".structure")); ret s == null ? null : unstructure(s); } static L slackUsersOnly(L vals) { // List comprehension syntax? // vals = [O val in vals where get(val, "user") != null]; new L l; for (O val : vals) if (get(get(val, "source"), "user") != null) l.add(val); ret l; }
Began life as a copy of #1002413
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: | #1002463 |
Snippet name: | Turing Tests: Dynamic Questions (added by #1002462) |
Eternal ID of this version: | #1002463/1 |
Text MD5: | 9fe797434af02c37e254cb81de214c47 |
Transpilation MD5: | e3eefab9ed541861a5fc4b909a4f869d |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-02 23:35:10 |
Source code size: | 1463 bytes / 54 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 879 / 2296 |
Referenced in: | [show references] |