Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!godot.cc.duq.edu!news.duke.edu!news.mathworks.com!newsfeed.internetmci.com!news.dacom.co.kr!usenet.seri.re.kr!news.cais.net!news.vbc.net!news.mira.net.au!inquo!news.seinf.abb.se!news.mdh.se!columba.udac.uu.se!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!news.chalmers.se!news.gu.se!hugin.cling.gu.se!cl3msalo
From: Mikael Salo <cl3msalo@cling.gu.se>
Subject: Re: Tail recursion optimisation? 
In-Reply-To: <4kshq7$iv4@styx.uwa.edu.au> 
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <Pine.SOL.3.91.960419201242.1195A-100000@hugin.cling.gu.se>
Sender: news@news.gu.se (USENET News System)
Nntp-Posting-Host: hugin.cling.gu.se
Organization: Gothenburg University
References: <4kshq7$iv4@styx.uwa.edu.au> 
Mime-Version: 1.0
Date: Fri, 19 Apr 1996 18:45:47 GMT
Lines: 33

I'm not sure what you really want but a way of using the memory 
dynamically is to use the predicates 'assert','asserta',assertz'

The use of these predicates can be found in the SICStus manual for 
built in's.....or by the Web: www.sics.se/isl/sicstus_44.html#SEC277

You must declare a predicate, say test (arity 1), this way:

:-dynamic test/1

The use of this predicate can then look like this:
Type at the prompt:
?-assert(test(a)).
?-assert(test(b)).
?-assert(test(c)).

Ask Prolog:
?-test(X).

The answer will be a,b,c respectively for X.

Try type 'listing' at the prompt to see what have happened.

What's good about this gadget is that by using the predicate
'retract' you can take away information thats of no use...

Well you can figure it out by looking in the manual....

Good luck

/Mikael Salo


