Function unify_sfunction

Source
pub fn unify_sfunction<'a>(
    name: &str,
    terms: &'a Vec<Unifiable>,
    other: &'a Unifiable,
    ss: &'a Rc<SubstitutionSet<'a>>,
) -> Option<Rc<SubstitutionSet<'a>>>
Expand description

Unify an SFunction with another Unifiable term.

When the function unify() tries to unify an SFunction with another term, it calls unify_sfunction(). This function evaluates its arguments (terms), and unifies the result with the other Unifiable term.

§Arguments

  • name of function
  • terms - vector of Unifiable terms
  • other Unifiable term
  • SubstitutionSet

§Returns

§Usage

use std::rc::Rc;
use suiron::*;

// Try:  $X = add(1, 2, 3)
let x = logic_var!(next_id(), "$X");
let ss = empty_ss!();
let terms = vec![SInteger(1), SInteger(2), SInteger(3)];

match unify_sfunction("add", &terms, &x, &ss) {
    Some(ss) => {
        let res = get_ground_term(&x, &ss).unwrap();
        println!("{}", res);
    },
    None => { println!("No solution."); },
}
// Should print: 6