Database class final

An indexed collection of Prolog Rule definitions that can be queried.

Rules are indexed by head functor name for fast candidate lookup during goal resolution.

For example:

final db = Database.parse('parent(tom, bob). parent(bob, ann).');
final goal = Term.parse('parent(tom, X)');
for (final result in db.query(goal)) {
  print(result); // parent(tom, bob)
}
Annotations
  • @immutable

Constructors

Database(Iterable<Rule> rules)
Creates a database populated with rules.
Database.parse(String rules)
Parses a string of Prolog rules into a Database.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
rules → Map<String, List<Rule>>
Map of rule head functor names to candidate rules.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query(Term goal) → Iterable<Node>
Queries the database with goal, yielding unified solution terms.
toString() → String
A string representation of this object.
override

Operators

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