🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3091

Re: Destructive predicates (random musings - part-I).

#3091
From: Richard A. O'Keefe
Date: Mon, 14 Mar 1988 07:50
24 lines
1344 bytes
In article <1797@sics.se>, alf@sics.se (Thomas Sj|land) writes:

> More bluntly put: A D-list is not an object in the Herbrand domain.

Right!  This is why I think it is a bad idea to use
	Front-Back
or	Front\Back
to package the two ends of a difference list as a single object,
and try always to use two separate arguments in my programs.

However, there is an encapsulation which works nicely, due I think to
Stuart Shieber, which Fernando Pereira told me about.

use	q(0, X, X)	for an empty list
and	q(s(s(...(0)...)), [X1,...,Xn|X], X)	for a list of N elements.

	empty_queue(q(0,X,X)).

	queue_first(X, q(s(N),[X|Front],Back), q(N,Front,Back)).

	queue_last(X, q(s(N),Front,Back), q(N,Front,[X|Back])).

queue_first(X, Queue1, Queue0) is analogous to List1 = [X|List0]
queue_last( X, Queue1, Queue0) is similar but works at the other end.
Technical Details
Message-ID: <772@cresswell.quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok
References: <7289@agate.BERKELEY.EDU> <716@sandino.quintus.UUCP> <1797@sics.se>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok
From: ok@quintus.UUCP (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: Destructive predicates (random musings - part-I).
Message-ID: <772@cresswell.quintus.UUCP>
Date: 14 Mar 88 07:50:33 GMT
References: <7289@agate.BERKELEY.EDU> <716@sandino.quintus.UUCP> <1797@sics.se>
Organization: Quintus Computer Systems, Mountain View, CA
Lines: 24
Keywords: Destructive predicates, LISP vs PROLOG Philosophy