!7 concept TheList { S name; new L entries; void add(S entry) { entries.add(entry); change(); } } concept Selection { TheList list; } static TheList list; // cache of the above p { dbIndexing(TheList, 'name); if ((list = uniq(Selection).list) == null) selectList("cool things"); botIfMain(); } synchronized answer { if "select *" { selectList($1); ret "OK, has " + n(list.entries, "entry"); } if "which" ret list.name; if "add *" { list.add($1); ret "OK, has position " + l(list.entries); } if "add * at *" { int i = parseInt($2)-1; list.entries.add(i, $1); list.change(); ret "OK"; } if "remove *" { int i = list.entries.indexOf($1); if (i < 0) ret "Not in list"; list.entries.remove(i); list.change(); ret "OK, removed from position " + (i+1); } if "length" ret lstr(list.entries); if "entry *" { S x = get(list.entries, parseInt($1)-1); ret x == null ? "Nuttn" : "Entry: " + quote(x); } if "fix lol" { cset(lol(), entries := collect(list(TheList), 'name)); ret "OK"; } } svoid selectList(S name) { if (!hasConcept(TheList, +name)) lol().add(name); cset(uniq(Selection), list := list = uniq(TheList, +name)); } // the "list of lists" static TheList lol() { ret uniq(TheList, name := "lol"); } static L knownCommands() { ret findSupportedQuestionsInFunctions('answer); }