From jan@swi.psy.uva.nl  Mon Jul 24 16:13:17 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id QAA26442;
	Mon, 24 Jul 2000 16:13:17 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id QAA02143;
	Mon, 24 Jul 2000 16:13:28 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: socher@fho-emden.de, Rolf Socher <socher@et-inf.fho-emden.de>,
        prolog@swi.psy.uva.nl
Subject: Re: setarg and backtracking
Date: Mon, 24 Jul 2000 16:09:30 +0200
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <00072414201200.01011@euler>
In-Reply-To: <00072414201200.01011@euler>
MIME-Version: 1.0
Message-Id: <00072416132804.23243@gollem>
Content-Transfer-Encoding: 8bit

On Mon, 24 Jul 2000, Rolf Socher wrote:
>Could it be that setarg/3 causes problems with backtracking? I call something
>like
> 	arg(N,Term,Value),
>	delete(Value,X,Value1),
>	setarg(N,Term,Value1)
>where Value is a list such as [1,2,3,4,5], and X is a number. When backtracking
>takes place on this branch, the variable Value has a value such as 
>	[1|_G150310]
>Can anybody help me with this problem?

Not sure what you try to do.  I think you misjudged the semantics of
delete/3.  I destilled the program below.

test(T, X) :-
	T = t([1,2,3,4,5]),
	test2(T, X).

test2(Term, X) :-
	arg(N,Term,Value),
	select(Value,X,Value1),
	setarg(N,Term,Value1).

Which produces:

?- test(L, X).

L = t([2, 3, 4, 5])
X = 1 ;

L = t([1, 3, 4, 5])
X = 2 ;

L = t([1, 2, 4, 5])
X = 3 ;

L = t([1, 2, 3, 5])
X = 4 ;

L = t([1, 2, 3, 4])
X = 5 ;

No

This looks ok to me.  If I'm wrong, please send a complete program so we
don't have to guess what you are doing.

	Regards --- Jan

P.s.	This is not advertisement for setarg/3, I think one should stay
	away from it whenever possible.  It is there mostly for
	compatibility reasons.

