Re: [eclipse-users] Retract

From: Wojciech Pieprzyca <behemot_at_...78...>
Date: Tue, 09 Oct 2007 18:27:44 +0200
I have a knowledge base with some facts loaded from a file e.g.
goods_possesed(oranges,0).
goods_possesed(apples,0).
goods_possesed(kiwi,0).
and then I intend to change some values dynamically e.g.
goods_possesed(oranges,5).
goods_possesed(apples,7).
goods_possesed(kiwi,3).
In classic Prolog it's possible to use retract predicate and then assert
changed facts.
I suppose that in ECLiPSe there are some better ways to gain the same 
result,
as you have written. Which non-logical storage is the best for this 
purpose ?

Wojtek.

Kish Shen pisze:
> Wojciech Pieprzyca wrote:
>> Dear users!
>>
>> I have got a very simple question.
>> Is it possible to remove (retract) facts loaded from static file ?
>> I try to use retract but this works only for facts declared
>> dynamically with assert predicate.
>>
>> Best regards,
>> Wojciech Pieprzyca
>>
>> _______________________________________________
>> ECLiPSe-Users mailing list
>> ECLiPSe-Users_at_...2...
>> http://www.crosscoreop.com/mailman/options/eclipse-users
>>   
> Hi Wojciech,
>
> I am not clear what you want to do: if you want to do dynamic 
> programming, i.e. you want to be able to assert and retract clauses 
> (not just facts) for a predicate, you can declare the predicate as 
> dynamic, e.g.
>
> :- dynamic foo/1.
>
> This can be done as a directive in the module you have the predicate 
> (foo/1), before any definitions of the predicate.  This can occur in a 
> file along with the rest of your code.
>
> You should really only do this if you want to modify your program at 
> run-time. If you want to simply store information, there are better 
> ways to do this in ECLiPSe -- see the `Non-logical Storage and 
> References' chapter of the User Manual:
>
> http://www.eclipse-clp.org/doc/userman/umsroot052.html
>
> If what you want to do is to remove code and definitions you loaded in 
> to a module, you can erase the whole module with the erase_module/1 
> built-in.
>
> Cheers,
>
> Kish
>
>
Received on Tue Oct 09 2007 - 17:27:59 CEST

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:19 CET