We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5bc4bd commit ab41033Copy full SHA for ab41033
src/simplify.jl
@@ -57,7 +57,18 @@ substitute any subexpression that matches a key in `dict` with
57
the corresponding value.
58
"""
59
function substitute(expr, dict)
60
- RuleSet([@rule ~x::(x->haskey(dict, x)) => dict[~x]])(expr)
+ RuleSet([@rule ~x::(x->haskey(dict, x)) => dict[~x]])(expr) |> fold
61
+end
62
+
63
+fold(x) = x
64
+function fold(t::Term)
65
+ tt = map(fold, arguments(t))
66
+ if !any(x->x isa Symbolic, tt)
67
+ # evaluate it
68
+ return operation(t)(tt...)
69
+ else
70
+ return Term{symtype(t)}(operation(t), tt)
71
+ end
72
end
73
74
### Predicates
0 commit comments