Database class

A Prolog clause database.

The database manages clauses (facts and rules) and supports:

  • Adding/removing clauses (assert/retract)
  • Retrieving clauses that match a goal
  • Pluggable storage engines

By default, uses in-memory storage with first-argument indexing.

Constructors

Database([Storage? storage])
Creates a database with the given storage engine.
Database.withStorage(Storage storage)
Creates a database with custom storage.
factory

Properties

clauses Iterable<Clause>
Returns all clauses in the database.
no setter
count int
Returns the total number of clauses.
no setter
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if the database is empty.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
storage Storage
Returns the underlying storage engine.
no setter

Methods

assert_(Clause clause) → void
Adds a clause to the database (assert).
asserta(Clause clause) → void
Adds a clause at the beginning of the database (asserta).
assertTerm(Term term) → void
Adds a term as a clause, handling DCG rules automatically.
assertz(Clause clause) → void
Adds a clause at the end of the database (assertz).
clear() → void
Clears all clauses from the database.
contains(Clause clause) bool
Returns true if the database contains the given clause.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retract(Clause clause) bool
Removes a clause from the database (retract).
retractAll(Term head) int
Removes all clauses matching the given head pattern (retractall).
retrieve(Term goal) Iterable<Clause>
Retrieves all clauses that potentially match the given goal.
retrieveByIndicator(String indicator) Iterable<Clause>
Retrieves all clauses for a given functor/arity indicator.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited