Warning: session_start(): open(/var/lib/php/sessions/sess_gg3lsetivopf5ohhkfihs7f220, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
concept TheList {
S name;
new L entries;
void add(S entry) {
entries.add(entry);
change();
}
}
concept Selection {
TheList list;
}
static TheList list;
p {
db();
list = uniq(Selection).list;
if (list == null) selectList("cool things");
if (isMainProgram()) botSleep();
}
synchronized answer {
if "select list *" {
selectList($1);
ret "OK, has " + n(theList().entries, "entry");
}
if "which list" {
ret list.name;
}
if "add * to list" {
theList().add($1);
theList().change();
ret "OK, has position " + l(theList().entries);
}
if "add * to list at position *" {
int i = parseInt($2)-1;
theList().entries.add(i, $1);
theList().change();
ret "OK";
}
if "take * out of list" {
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 of list"
ret lstr(theList().entries);
if "entry * in list" {
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);
}
static TheList lol() {
ret uniq(TheList, "list of lists");
}
svoid fixLOL {
lol().entries = collect(list(TheList), 'name);
lol().change();
}