memo.scm 695 Bytes
Newer Older
1 2 3 4 5
(use-modules (logic guile-log))
(use-modules (logic guile-log iso-prolog))
(use-modules (logic guile-log memoize))
(use-modules (logic guile-log umatch))
(use-modules (logic guile-log vlist))
6
(use-modules (logic guile-log guile-prolog canon))
7 8 9 10 11
(use-modules (logic guile-log guile-prolog interleave))
(define s (fluid-ref *current-stack*))
(compile-prolog-string
"
-functorize(tabling).
12
ff(X) :- (X=[Y,A,B]),ff(A),ff(B),(Y=1;Y=2).
13 14 15 16

-functorize(with_canon).
f(X) :- ff(X).

17 18 19 20
-functorize(tabling).
f2(X) :- \\+f2(X).
-functorize(tabling).
f3(X) :- X=[1|Y],\\+\\+f3(Y).
21
") 
22 23 24 25

(compile-prolog-string
"
-functorize(tabling).
26 27 28 29
gg(X) :- gg(Y),(X=[1|Y];X=[2|Y]).

-functorize(with_canon).
g(X) :- gg(X).
30 31
")