Warning: session_start(): open(/var/lib/php/sessions/sess_0i1ilap7psi6vo1dvdon7hj31b, 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
sbool lispMatch_debug;
static Map lispMatch(Lisp pat, Lisp nl, Collection variables) {
new Map matches;
ret lispMatch_sub(pat, nl, variables, matches) ? matches : null;
}
static bool lispMatch_sub(Lisp pat, Lisp nl, Collection variables, Map m) {
if (pat == null || nl == null) ret false;
if (pat.isLeaf() && variables.contains(pat.head)) {
if (lispMatch_debug) print("Var: " + pat.head + " => " + nl);
ret lispMatch_putMatch(m, pat.head, nl);
}
if (neq(pat.head, nl.head)) ret false;
// heads identical, proceed to children
int n = pat.size();
if (n != nl.size()) ret false;
for (int i = 0; i < n; i++) {
if (lispMatch_debug) print("Sub " + i + ": " + pat.get(i) + " => " + nl.get(i));
if (!lispMatch_sub(pat.get(i), nl.get(i), variables, m))
false;
}
true;
}
static bool lispMatch_putMatch(Map matches, S key, Lisp val) {
if (matches.containsKey(key)) {
if (neq(matches.get(key), val))
false;
//fail("multi-matching not implemented");
}
matches.put(key, val);
true;
}