Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!newsfeed.internetmci.com!howland.reston.ans.net!nntp.coast.net!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: In situ list manipulation ?
Message-ID: <9600800.17108@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <4cm652$6sq$1@mhafn.production.compuserve.com>
Date: Sun, 7 Jan 1996 13:04:06 GMT
Lines: 28

Charles-Andr Brouwers <101370.277@CompuServe.COM> writes:

>It is possible to manipulate list in situ in prolog as you do in 
>Lisp by using the setf function.
>
>For example is possible to translate (setf (cdr '(a b)) 'c) where 
>the result of the call
> '(a. c) is not a copy of the initial argument but the initial list 
>changed in situ.
>
>
>In prolog this would look like  
>
>?- ((L is [a,b]), setfcdr(L,c)).
>
>C = [a|c]

I'm curious - is there really some obscure dialect of Prolog that
supports such code?  Certainly none of the three Prolog systems 
I have on hand will accept it.

There *is* a builtin setarg/3 that you can use for backtrackable
destructive update in two of those three Prolog systems.  But there is
not portable or standard-conforming way of doing it.

--
Fergus Henderson             	WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au              	PGP: finger fjh@128.250.37.3
