Re: [eclipse-clp-users] Want to indicate which arg position causes unification to fail

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Tue, 20 Mar 2012 02:07:00 +0100
-dp- wrote:
> I've looked through the user manual for v6.1 (64bit) about debugging and 
> about events, and searched through old postings...but found no answer.
> 
> I would like to create a predicate that performs unification but also, 
> in case unification fails, indicates which arg position was responsible 
> for the failure. Does the builtin unifier provide any hooks for this info?

You can break up unification like this

unify(X, Y) :-
	functor(X, F, A),
	functor(Y, F, A),	% fail if different functors (or atomic terms)
	( for(I,1,A), param(X,Y) do
	     arg(I, X, XI),
	     arg(I, Y, YI),
	     unify(XI, YI)	% unify argument I
	).

and then instrument this code.


-- Joachim
Received on Tue Mar 20 2012 - 01:07:07 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST