Unificeren met occurs check

Log in om je oplossingen te testen.
% unify(Term1,Term2) :- % Term1 and Term2 are unified. ignoring the occurs check. unify(X, Y) :- var(X), var(Y), X=Y. unify(X, Y) :- var(X), nonvar(Y), X=Y. unify(X, Y) :- nonvar(X), var(Y), X=Y. unify(X, Y) :- nonvar(X), nonvar(Y), atomic(X), atomic(Y), X=Y. unify(X, Y) :- nonvar(X), nonvar(Y), compound(X), compound(Y), functor(X, F, N), functor(Y, F, N), unify_args(N, X, Y). unify_args(N, X, Y) :- N>0, unify_arg(N, X, Y), N1 is N-1, unify_args(N1, X, Y). unify_args(0, _, _). unify_arg(N, X, Y) :- arg(N, X, ArgX), arg(N, Y, ArgY), unify(ArgX, ArgY).
Je kunt zo vaak indienen als je wenst. Er wordt enkel rekening gehouden met je laatst ingediende oplossing.
Log in om je oplossingen te testen.