Re: Remove all asserted facts?

From: Paul Tarau (ptarau_at_yahoo.com)
Date: 08/26/04


Date: 26 Aug 2004 13:14:07 -0700


"news.adelphia.net" <no-mail-please@nospam.com> wrote in message news:<O4GdnY0PNb08MLHcRVn-oQ@adelphia.com>...
> I want to remove all facts that were instantiated by the assert() statement
> (I want to reset the Prolog database). I tried:
>
> retractall(_).
>
> But I got an instantiation error. What's the most convenient way to do
> this?
>
> Thanks.

In systems with multiple dynamic databases like BinProlog or Jinni
you can use operations like *db_clean(DataBaseName)* to achieve this
efficiently. In any case, using *abolish* is faster than *retractall*
which has to linearly scan all clauses - not a very smart thing given
that you want all of them removed! Having to keep track of your
asserted predicates is clearly no fun - you might want to use things
like *current_predicate* for doing this automatically - but again,
that
adds unpleasant complexity, performace hits and/or non-portability
to your code.

Paul Tarau

=============================================================
New Jinni3D Prolog toolkit with high-level agent oriented
API, supporting morphing, 3D-avatar animation, 3D-graph layout
and more - is now available from http://www.binnetcorp.com
=============================================================



Relevant Pages

  • Re: Remove all asserted facts?
    ... > (I want to reset the Prolog database). ... > But I got an instantiation error. ... You probably need to keep track of which facts you're likely to assert ...
    (comp.lang.prolog)
  • Remove all asserted facts?
    ... I want to remove all facts that were instantiated by the assert() statement ... (I want to reset the Prolog database). ... But I got an instantiation error. ...
    (comp.lang.prolog)