List handling predicates and unification of variables

Suggestions for new Logtalk features

Moderator: Paulo Moura

Post Reply
Victor NOEL
Posts: 48
Joined: Tue May 15, 2007 4:53 pm

List handling predicates and unification of variables

Post by Victor NOEL » Fri Jul 18, 2008 10:57 am

Hello,

I am currently playing with constraints and as they are manipulated using variables, I had a few problems using existing predicates for manipulating lists.

Some of them unify variables (=), some not, for example in list.lgt, they all unify variable, but sort/2 does not.

And in varlist.lgt, they are not unified (==).

In set.lgt, they seems to be unified ... and so on.

And some times, I don't want neither to unify them (=) nor just compare them (==) but I want to compare them without unifying them (=@= or maybe copy_term/2 (who keep the constraints but duplicate the variables) ?)

All of this is very complex, I am wondering what can be done to simplify all of this.

I don't have currently an answer to this, but maybe a discussion can take place on the subject.

It can be just a better documentation of the libraries, or maybe the creation of a library for each one of the kind of comparison/unification ...

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: List handling predicates and unification of variables

Post by Paulo Moura » Fri Jul 25, 2008 1:17 am

Victor NOEL wrote: I am currently playing with constraints and as they are manipulated using variables, I had a few problems using existing predicates for manipulating lists.

Some of them unify variables (=), some not, for example in list.lgt, they all unify variable, but sort/2 does not.
Currently, the library predicate sort/2 simply uses the Prolog built-in sort predicate.
Victor NOEL wrote: And in varlist.lgt, they are not unified (==).

In set.lgt, they seems to be unified ... and so on.

And some times, I don't want neither to unify them (=) nor just compare them (==) but I want to compare them without unifying them (=@= or maybe copy_term/2 (who keep the constraints but duplicate the variables) ?)

All of this is very complex, I am wondering what can be done to simplify all of this.
One option is defining a parametric object whose parameter would be the predicate that should be used to compare two list elements. Of course, this implies the use of meta-calls with the consequent performance penalties. However, if you limit the possible parameter values, you could go for a simpler solution that does not imply meta-calls. Another option would be to define specialized versions of the library "list" predicate, as you suggested.

Cheers,

Paulo
Paulo Moura
Logtalk developer

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest