This program works in Visual Prolog 7.3 but does not work in Visual Prolog 7.4:

Code: Select all

```
class facts
tr : dictionary{dictionary{unsigned}} := empty.
class predicates
tryGet : (unsigned, unsigned) -> unsigned determ.
setVal : (unsigned, unsigned, unsigned).
clauses
tryGet(X, Y) = lookup(lookup(tr, X), Y).
setVal(X, Y, V):-
Tree = lookup(tr, X),
!,
tr := insert({(A, _) = A}, tr, X, insert({(A, _) = A}, Tree, Y, V));
tr := insert({(A, _) = A}, tr, X, insert({(A, _) = A}, empty, Y, V)).
class predicates
f : (unsigned X, unsigned Y) -> unsigned Val.
clauses
f(0, Y) = Y + 1:- !.
f(X, Y) = V:-
V = tryGet(X, Y),
!.
f(X, Y) = V:-
(Y = 0, !, V = f(X - 1, 1);
V = f(X - 1, f(X, Y - 1))),
setVal(X, Y, V).
domains
tuple4 = tuple{unsigned X, unsigned Y, unsigned V, unsigned}.
class predicates
g : (unsigned, unsigned) -> unsigned.
g : (unsigned, unsigned, tuple4) -> unsigned.
nextVal : (tuple4) -> tuple4.
clauses
g(X, Y) = g(X, Y, tuple(0, 0, 1, 1)):-
tr := empty,
setVal(0, 1, 0).
g(X, Y, tuple(X, Y, Z, _)) = Z:- !.
g(X, Y, T) = g(X, Y, T1):-
T1 = nextVal(T),
T1 = tuple(A, B, C, _),
setVal(A, C, B).
nextVal(tuple(X, 1, V, N)) = tuple(X + 1, 0, V, N):- !.
nextVal(tuple(X, Z, V, N)) = tuple(X + 1, Y + 1, V, N):-
Y = tryGet(X + 1, Z),
!.
nextVal(tuple(_, _, _, N)) = tuple(0, N, N + 1, N + 1).
run():-
write(f(3, 13)), nl,
write(g(3, 14)),
_ = readLine().
```