Newsgroups: comp.lang.lisp,comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!pipex!sunic!umdac!fizban.solace.mh.se!news.ifm.liu.se!liuida!aste31.ida.liu.se!andka
From: andka@ida.liu.se (Andreas Kagedal)
Subject: Re: Knowledge Works Help Request
In-Reply-To: speedc@cs.man.ac.uk's message of 1 Dec 1994 10: 14:23 GMT
Message-ID: <ANDKA.94Dec2091841@aste31.ida.liu.se>
Sender: news@ida.liu.se
Organization: IDA, Linkping University, Sweden
References: <3bk7lv$iq7@m1.cs.man.ac.uk>
Date: Fri, 2 Dec 1994 08:18:41 GMT
Lines: 32
Xref: glinda.oz.cs.cmu.edu comp.lang.lisp:15898 comp.lang.prolog:11866

I don't know what KW is, but since you mention Prolog as beeing involved
and describing something I recogize as a common Prolog-beginner problem,
here is a sugested answer.

In difference to languages you have seen before, a prolog variable does
denote not a memory location where a value could be put. Instead it
deonte one (perhaps unknown) value. This means that you can never change
the value of a variable once it has got one.

Saying somthing like ?var = ?var + 1 is the same as saying that, for
instance, 10 = 10 + 1, which is obviously always false. This is, I
guess, exactly what you do when you write ((+ ?var 1) ?var),
i.e. requiring that (+ ?var 1) and ?var both should represent the same
value, which they don't.

What you have to do instead is to invent a new variable name that gets
the new value, something like ((+ ?var 1) ?newvar), and then use ?newvar
instead of ?var in the rest of the clause/rule.

/Andreas
--
----------------------------------- < * > ------------------------------------
Andreas Kagedal                                email: andka@IDA.LIU.SE
Dep. of Computer and information science
Linkoping University, Sweden

--
----------------------------------- < * > ------------------------------------
Andreas Kagedal                                email: andka@IDA.LIU.SE
Dep. of Computer and information science
Linkoping University, Sweden

