Prolog/Modifying the Database

      This page is a stub.

      From the SWI manual: [1]

      asserta(+Term)
      Assert a fact or clause in the database. Term is asserted as the firsr fact or clause of the corresponding predicate. Equivalent to assert/1, but Term is asserted as first clause or fact of the predicate.
      
      assertz(+Term, -Reference)
      Equivalent to asserta/1, asserting the new clause as the last clause of the predicate.
      
      retract(+Term)
      When Term is an atom or a term it is unified with the first unifying fact or clause in the database. The fact or clause is removed from the database.
      
      retractall(+Head)
      All facts or clauses in the database for which the head unifies with Head are removed. If Head refers to a predicate that is not defined, it is implicitly created as a dynamic predicate. See also dynamic/1.35
      
      

      Examples:

      Let's start with an empty database:

      ?- human(john).
      ERROR: toplevel: Undefined procedure: human/1 (DWIM could not correct goal)
      
      ?- assert(human(john)).
      true.
      
      ?- human(X).
      X = john.
      
      ?- 
      
      Last modified on 12 April 2012, at 22:07