logicrs 0.6.1

Rust library for logic expression
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use super::{Term, TermType};
use std::ops::Deref;

impl Term {
    pub fn replace(&self, x: &Term, y: &Term) -> Term {
        if self.eq(x) {
            return y.clone();
        }
        let TermType::Op(op) = self.deref() else {
            return self.clone();
        };
        let terms: Vec<_> = op.terms.iter().map(|t| t.replace(x, y)).collect();
        Term::new_op(op.op.clone(), &terms)
    }
}