🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1909

Re: Another question on pointers and Prolog.

#1909
From: Thanasis Mitsolides
Date: Thu, 28 Feb 1991 19:45
34 lines
2035 bytes
/ micha@ecrc.de (Micha Meier) /  4:33 am  Feb 27, 1991 */
In article <2142@n-kulcs.cs.kuleuven.ac.be> bimandre@icarus.cs.kuleuven.ac.be (Andre Marien) writes:
>il([E|L]) :- il(L,[E|L]) .
>
>il(L,L) :- ! . % part of list unifies with list
>il([_,_|L1],[_|L2]) :-
>	il(L1,L2) .

	Note that some Prolog systems do compare the pointers
	deep in the unification Procedure, in order to save time
	when two identical terms are unified, so that the above program
	succeeds on lists like X=[a|X], but it still loops with X=[a, a|X].

What do you mean by "deep in the recursion"?
Most Prolog systems compare pointers immidiately and always.
The reason X=[a|X] or X[a, a, a|X] etc succeed
while X=[a,a|X] or X=[a,a,a,a|X] etc. fail is that
in the first case the unification operation eventually tries to unify
the same pointers while in the second case that never happens.

In other words, the reason "X=[a,a|X], il(X)" does not succeed
is the same for which "X=[a|X], Y=[a|Y], X=Y" does not succeed.

Thanasis

-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu	             (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP    : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
Internet: mitsolid@cs.nyu.edu	             (mitsolid%cs.nyu.edu@relay.cs.net)
UUCP    : ...!uunet!cmcl2!cs!mitsolid
-------------------------------------------------------------------------------
Technical Details
Message-ID: <12600004@acf5.NYU.EDU>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!acf5!mitsolid
References: <18129@cs.utexas.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!acf5!mitsolid
From: mitsolid@acf5.NYU.EDU (Thanasis Mitsolides)
Newsgroups: comp.lang.prolog
Subject: Re: Another question on pointers and Prolog.
Message-ID: <12600004@acf5.NYU.EDU>
Date: 28 Feb 91 19:45:00 GMT
References: <18129@cs.utexas.edu>
Sender: notes@cmcl2.nyu.edu (Notes Person)
Organization: New York University
Lines: 34
Nntp-Posting-Host: acf5.nyu.edu