pub fn evaluate_expr(expr: RcExpr, rules: &[Rule], ctxt: &ProgramContext) -> RcExpr {
    let mut simplified_expr = expr;
    // Try simplifying the expression with a rule set until the same expression is seen again,
    // meaning we can't simplify any further or are stuck in a cycle.
    let mut expr_hash = hash(&simplified_expr);
    let mut seen: HashSet<u64> = HashSet::new();
    if ctxt.always_flatten {
        simplified_expr = flatten_expr(simplified_expr);
    }
    while seen.insert(expr_hash) {
        for rule in rules {
            simplified_expr = rule.transform(simplified_expr);
        }
        expr_hash = hash(&simplified_expr);
    }

    normalize(simplified_expr)
}
/// Evaluates an expression to as simplified a form as possible.
/// The evaluation may be partial, as some values (like variables) may be unknown.
/// The returned expression is normalized.
Evaluates an expression to as simplified a form as possible.
The evaluation may be partial, as some values (like variables) may be unknown.
The returned expression is normalized.
Evaluates an expression to as simplified a form as possible . The evaluation may be partial as some values ( like variables ) may be unknown . The returned expression is normalized .
pub fn evaluate_expr(expr: RcExpr, rules: &[Rule], ctxt: &ProgramContext) -> RcExpr {
    let mut simplified_expr = expr;
    // Try simplifying the expression with a rule set until the same expression is seen again,
    // meaning we can't simplify any further or are stuck in a cycle.
    let mut expr_hash = hash(&simplified_expr);
    let mut seen: HashSet<u64> = HashSet::new();
    if ctxt.always_flatten {
        simplified_expr = flatten_expr(simplified_expr);
    }
    while seen.insert(expr_hash) {
        for rule in rules {
            simplified_expr = rule.transform(simplified_expr);
        }
        expr_hash = hash(&simplified_expr);
    }
    normalize(simplified_expr)
}
pub fn evaluate_expr ( expr : RcExpr , rules : & [ Rule ] , ctxt : & ProgramContext ) -> RcExpr { let mut simplified_expr = expr ; // Try simplifying the expression with a rule set until the same expression is seen again, // meaning we can't simplify any further or are stuck in a cycle. let mut expr_hash = hash ( & simplified_expr ) ; let mut seen : HashSet < u64 > = HashSet :: new ( ) ; if ctxt . always_flatten { simplified_expr = flatten_expr ( simplified_expr ) ; } while seen . insert ( expr_hash ) { for rule in rules { simplified_expr = rule . transform ( simplified_expr ) ; } expr_hash = hash ( & simplified_expr ) ; } normalize ( simplified_expr ) }
Evaluates an expression to as simplified a form as possible.
Evaluates an expression to as simplified a form as possible .
expr
RcExpr
rules
&[Rule]
ctxt
&ProgramContext
expr
RcExpr
rules
&[Rule]
ctxt
&ProgramContext