pub fn unify(&self, pattern: &Atom) -> Vec<(Bindings, Unifications)> {
        log::debug!("unify: pattern: {}", pattern);
        let mut result = Vec::new();
        for next in &(*self.borrow_vec()) {
            match matcher::unify_atoms(next, pattern) {
                Some(res) => {
                    let bindings = matcher::apply_bindings_to_bindings(&res.candidate_bindings, &res.pattern_bindings);
                    if let Ok(bindings) = bindings {
                        // TODO: implement Display for bindings
                        log::debug!("unify: push result: {}, bindings: {:?}", next, bindings);
                        result.push((bindings, res.unifications));
                    }
                },
                None => continue,
            }
        }
        result
    }
// TODO: for now we have separate methods query() and unify() but
// they probably can be merged. One way of doing it is designating
// in the query which part of query should be unified and which matched.
// For example for the typical query in a form (= (+ a b) $X) the
// (= (...) $X) level should not be unified otherwise we will recursively
// infer that we need calculating (+ a b) again which is equal to original
// query. Another option is designating this in the data itself.
// After combining match and unification we could leave only single
// universal method.
for now we have separate methods query() and unify() but
they probably can be merged. One way of doing it is designating
in the query which part of query should be unified and which matched.
For example for the typical query in a form (= (+ a b) $X) the
(= (...) $X) level should not be unified otherwise we will recursively
infer that we need calculating (+ a b) again which is equal to original
query. Another option is designating this in the data itself.
After combining match and unification we could leave only single
universal method.
for now we have separate methods query () and unify () but they probably can be merged . One way of doing it is designating in the query which part of query should be unified and which matched . For example for the typical query in a form ( = ( + a b ) $X ) the ( = ( ... ) $X ) level should not be unified otherwise we will recursively infer that we need calculating ( + a b ) again which is equal to original query . Another option is designating this in the data itself . After combining match and unification we could leave only single universal method .
pub fn unify(&self, pattern: &Atom) -> Vec<(Bindings, Unifications)> {
        log::debug!("unify: pattern: {}", pattern);
        let mut result = Vec::new();
        for next in &(*self.borrow_vec()) {
            match matcher::unify_atoms(next, pattern) {
                Some(res) => {
                    let bindings = matcher::apply_bindings_to_bindings(&res.candidate_bindings, &res.pattern_bindings);
                    if let Ok(bindings) = bindings {
                        // TODO: implement Display for bindings
                        log::debug!("unify: push result: {}, bindings: {:?}", next, bindings);
                        result.push((bindings, res.unifications));
                    }
                },
                None => continue,
            }
        }
        result
    }
pub fn unify ( & self , pattern : & Atom ) -> Vec < ( Bindings , Unifications ) > { log :: debug ! ( " " pattern ) ; let mut result = Vec :: new ( ) ; for next in & ( * self . borrow_vec ( ) ) { match matcher :: unify_atoms ( next , pattern ) { Some ( res ) => { let bindings = matcher :: apply_bindings_to_bindings ( & res . candidate_bindings , & res . pattern_bindings ) ; if let Ok ( bindings ) = bindings { // TODO: implement Display for bindings log :: debug ! ( " " next bindings ) ; result . push ( ( bindings , res . unifications ) ) ; } } , None => continue , } } result }
TODO: for now we have separate methods query() and unify() but
they probably can be merged.
TODO : for now we have separate methods query () and unify () but they probably can be merged .
&self
pattern
&Atom
&self
pattern
&Atom