Facilities of Mercury
Fergus Henderson
fjh at cs.mu.oz.au
Thu Mar 6 01:12:59 AEDT 1997
Serap Yilmaz, you wrote:
>
> Regarding 3, I actually use nonvar/1 and functor/3 in order to compare
> two terms in terms of their functor and arities. The corresponding
> Prolog program that I would write is:
>
> comparable(T1,T2) :-
> nonvar(T1),
> nonvar(T2),
> functor(T1, F, N),
> functor(T2, F, N).
> Another question: how can I test if two neither non-ground nor ground
> terms are equal i.e. terms like g(A,b,R). This is == in Prolog, and
> what is corresponding operator for ~= in Mercury?
I'm still missing the big picture here -- what is the real problem
that you are trying to solve? What do these non-ground terms represent?
Why do you need to compare them?
Often the right way to solve these sorts of problems in Mercury is
to use a ground representation; see the standard library module `term'
for an example. However, without knowing more about your application,
it's hard to give definitive advice.
(Note that using `term' may also avoid the need for `arg' and `functor'.)
Cheers,
Fergus.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the users
mailing list