Skip to content

Commit

Permalink
Merge pull request #822 from vsbogd/cleanup-bindings-code
Browse files Browse the repository at this point in the history
Cleanup unification related code after old interpreter is removed
  • Loading branch information
vsbogd authored Dec 16, 2024
2 parents 1abf166 + f0d36a1 commit b0b92c4
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 127 deletions.
4 changes: 2 additions & 2 deletions c/src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ pub extern "C" fn bindings_add_var_binding(bindings: *mut bindings_t, var: atom_
_ => panic!("var argument must be variable atom")
};
let atom = atom.into_inner();
match bindings.clone().add_var_binding_v2(var, atom) {
match bindings.clone().add_var_binding(var, atom) {
Ok(new_bindings) => {
*bindings = new_bindings;
true
Expand Down Expand Up @@ -1309,7 +1309,7 @@ pub extern "C" fn bindings_merge(_self: bindings_t, other: *const bindings_t) ->
let other = unsafe{ &*other }.borrow();
let owned_self = _self.into_inner();

let new_set = owned_self.merge_v2(other);
let new_set = owned_self.merge(other);
new_set.into()
}

Expand Down
9 changes: 5 additions & 4 deletions lib/examples/custom_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ impl Grounded for TestDict {
impl CustomMatch for TestDict {
fn match_(&self, other: &Atom) -> MatchResultIter {
if let Some(other) = other.as_gnd::<TestDict>() {
other.0.iter().map(|(ko, vo)| {
Box::new(other.0.iter().map(|(ko, vo)| {
self.0.iter().map(|(k, v)| {
match_atoms(&Atom::expr(vec![k.clone(), v.clone()]), &Atom::expr(vec![ko.clone(), vo.clone()]))
}).fold(Box::new(std::iter::empty()) as MatchResultIter, |acc, i| {
Box::new(acc.chain(i))
})
}).fold(Box::new(std::iter::once(Bindings::new())),
|acc, i| { matcher::match_result_product(acc, i) })
}).collect::<BindingsSet>()
}).fold(BindingsSet::single(),
|acc, i| { acc.merge(&i) })
.into_iter())
} else {
Box::new(std::iter::empty())
}
Expand Down
Loading

0 comments on commit b0b92c4

Please sign in to comment.