!752 m { // subject, object (S/O can be verbs, nouns, anything) static class SO { S s, o; int value; // 1 = asserted as true, -1 = asserted as false *(S *s, S *o) {} *(S *s, S *o, int *value) {} *() {} public boolean equals(O _o) { if (!(_o instanceof SO)) ret false; SO x = cast _o; ret eq(s, x.s) && eq(o, x.o); } } static new L data; static void store(S s, S o, int value) { data.add(new SO(s, o, value)); } static int query(S s, S o) { int i = data.indexOf(new SO(s, o)); ret i >= 0 ? data.get(i).value : 0; } static S answer(S s) { new Matches m; if (match("query * *", s, m)) ret string(query(m.unq(0), m.unq(1))); if (match("assert * *", s, m)) { store(m.unq(0), m.unq(1), 1); ret "OK."; } if (match("assertnot * *", s, m)) { store(m.unq(0), m.unq(1), -1); ret "OK."; } ret null; } p { store("we can wait", "1 second", 1); store("we can wait", "60 seconds", -1); assertEq(1, query("we can wait", "1 second")); assertEq(-1, query("we can wait", "60 seconds")); assertEq(0, query("we can wait", "10 seconds")); print("OK!"); } }