I'm using library assoc
from SWI-Prolog. Here's a query which confuses me:
?- empty_assoc(E), put_assoc(K, E, V, E2), get_assoc(key, E2, 2).
false.
Why doesn't this unify? I'd expect it to unify with
E = t,
K = key
V = 2,
E2 = t(key, 2, -, t, t).
The put_assoc/4
predicate must be called with a bound key and value. Try e.g.
?- empty_assoc(E), put_assoc(key, E, 2, E2), get_assoc(key, E2, V).
E = t,
E2 = t(key, 2, -, t, t),
V = 2.