[mercury-users] list rotation in Mercury

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Jul 14 13:40:53 AEST 2001


On 13-Jul-2001, Terrence Brannon <tmbranno at oracle.com> wrote:
> 
> I looked through the list library and did not see a rotate predicate
> available. Per. p. 57 of "Clause and Effect", the implementation makes
> us of difference structures. But recently Richard stated that
> incomplete data structures were a feature of Prolog missing from
> Mercury. Is this the case?
> 
> rotall( [] , A , []).
> rotall([H|T], A, [L|Z]) :-
> 	     append([H|T], A, L),
> 	     append(A,[H], A1),
> 	     rotall(T, A1, Z).

I don't have a copy of "Clause and Effect", I'm afraid,
I have trouble seeing how this example uses difference structures.
Normally difference lists are used to *avoid* calls to append/3.

The code you've given for rotall/3 works fine in Mercury in the
(in, in, out) mode.

It might help if you show the query that calls rotall/3. 
Whether or not a procedure like rotall/3 uses difference structures will
in general depend on what mode it is called it.  Without seeing a specific
call to rotall/3, it's difficult to see what mode it is intended to be used in.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list