query method
Implementation
@override
Stream<Node> query(Database database) async* {
Stream<Node> solutions(int index, Map<Variable, Node> bindings) async* {
if (index < arguments.length) {
final arg = arguments[index];
final subs = arg.substitute(bindings) as Term;
await for (final item in database.query(subs)) {
final unified = mergeBindings(arg.match(item), bindings);
if (unified != null) {
yield* solutions(index + 1, unified);
}
}
} else {
yield substitute(bindings);
}
}
yield* solutions(0, newBindings());
}