🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3717

Copying

#3717
From: gerdeman
Date: Wed, 19 Oct 1988 16:45
15 lines
875 bytes
Sterling and Shapiro give the following procedure for copying:

copy(X,Y):- assert('$foo'(X)),retract('$foo'(Y)).

I have found the following to be much faster:

copy(X,Y):- findall(Z, Z = X,[Y]).

This only works with findall not setof or bagof. Can anyone
explain why this works? In general, I have discovered, destructive
variable bindings embedded within findall have no global effect.
Again this is not the case with setof and bagof. Very peculiar
isn't it?
                          --- Dale Gerdemann
Technical Details
Message-ID: <16400001@clio>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!ncar!tank!uxc!uxc.cso.uiuc.edu!clio!gerdeman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!ncar!tank!uxc!uxc.cso.uiuc.edu!clio!gerdeman
From: gerdeman@clio.las.uiuc.edu
Newsgroups: comp.lang.prolog
Subject: Copying
Message-ID: <16400001@clio>
Date: 19 Oct 88 16:45:00 GMT
Lines: 14
Nf-ID: #N:clio:16400001:000:508
Nf-From: clio.las.uiuc.edu!gerdeman    Oct 19 11:45:00 1988