Hi Wojciech , Wojciech Pieprzyca wrote: > 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. > You can do this in ECLiPSe as well. But note that this does not update the predicates in your file -- this is the case in ECLiPSe as well as other Prologs. > 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 ? > You could use non-logical variables, which you can declare with a directive like: :- local variable(oranges, 0). and you can use getval/2 and setval/2 to read and change the value. but if you want the new values to presist, i.e. when you next start an ECLiPSe session, you want the new values, then you should write the data into a file, and read that in when you run your program. You could also use a database to store your values (e.g. using lib(dbi)). Cheers, Kish > 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 >> >> >> > > > _______________________________________________ > ECLiPSe-Users mailing list > ECLiPSe-Users_at_...2... > http://www.crosscoreop.com/mailman/options/eclipse-users >Received on Tue Oct 09 2007 - 21:05:32 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST