macro_rules! query {
($($term:expr),*) => { ... };
}
Expand description
Creates a query from a list of terms.
A query is a Goal, a logic expression to be solved.
It has the same form as a
complex term,
consisting of a functor with arguments (terms) enclosed in parentheses:
functor(term1, term2, term3)
.
The functor must be an atom, but a term can be any unifiable term.
This utility calls make_query(), which clears the logic variable ID, and recreates all logic variables within the query.
The macro returns an Rc pointer to the newly created query, which can be passed to the function make_base_node().
See also: parse_query()
ยงUsage
use std::rc::Rc;
use suiron::*;
let kb = test_kb();
let functor = atom!("loves");
let who = logic_var!("$Who");
let penny = atom!("Penny");
// Query is: loves($Who, Penny).
let query = query!(functor, who, penny);
let base_node = make_base_node(Rc::clone(&query), &kb);
println!("{}", solve(base_node)); // Prints: $Who = Leonard