🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.prolog
Article #645

Re: eliminating duplicate solutions in Prolog

#645
From: Lars-Henrik Eriksson
Date: Sat, 31 May 1986 05:52
31 lines
2101 bytes
In article <126@sbcs.UUCP> debray@sbcs.UUCP writes:
>.... I'm thinking of the rather
>mundane fact that any "real" system, to be useful, must interact with the
>outside world, and hence necessarily have side effects like "read"
>and "write".  .....

I/o must do side effects, of course, but it is quite possible to hide this
from a logic program, so that it appears to be in a completely "logical"
environment.

Example: Input could be done in a logical fashion by having a special kind of
list with elements corresponding to successive objects read from the outside
world. That is, the list would initially be an uninstantiated variable.
Attempts to use the variable would cause an object to be read in and the
variable would be bound to a pair of the first element and another 
uninstantiated variable. Attempts to use the rest of the list would cause
the process to be repeated.

That is, to the program, the list would look like it had everything read in
on it from the start, but actually things would be read in only as they
were needed. 

Of course, special precautions would have to be taken to make sure this
worked when the program backtracked, but it is quite possible. (In fact, I
have implemented input working in this way).

Output could be done in a similar way, with objects being output as a list
was bound.

In both cases the program would think it was processing or creating a list,
while it was actually reading or writing.
Technical Details
Message-ID: <1164@sicsten.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!lll-crg!seismo!mcvax!enea!sicsten!lhe
References: <126@sbcs.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!lll-crg!seismo!mcvax!enea!sicsten!lhe
From: lhe@sicsten.UUCP (Lars-Henrik Eriksson)
Newsgroups: net.lang.prolog
Subject: Re: eliminating duplicate solutions in Prolog
Message-ID: <1164@sicsten.UUCP>
Date: Sat, 31-May-86 01:52:16 EDT
Article-I.D.: sicsten.1164
Posted: Sat May 31 01:52:16 1986
Date-Received: Tue, 3-Jun-86 04:42:50 EDT
References: <126@sbcs.UUCP>
Reply-To: lhe@sicsten.UUCP (Lars-Henrik Eriksson)
Distribution: net
Organization: Swedish Institute of Computer Science
Lines: 31