@@ -73,13 +73,11 @@ The returned value should either be a value or an expression involving symbolic
7373not present as keys in `syms`.
7474
7575This is already implemented for
76- `symbolic_evaluate(expr::Union{Symbol, Expr}, syms::Dict{Symbol} )`.
76+ `symbolic_evaluate(expr::Union{Symbol, Expr}, syms::Dict)`.
7777"""
78- function symbolic_evaluate (expr:: Union{Symbol, Expr} , syms:: Dict{Symbol} )
79- while (new_expr = MacroTools. postwalk (expr) do sym
80- return get (syms, sym, sym)
81- end ) != expr
82- expr = new_expr
78+ function symbolic_evaluate (expr:: Union{Symbol, Expr} , syms:: Dict )
79+ while (newexpr = _symbolic_evaluate_helper (expr, syms)) != expr
80+ expr = newexpr
8381 end
8482 return try
8583 eval (expr)
@@ -88,6 +86,20 @@ function symbolic_evaluate(expr::Union{Symbol, Expr}, syms::Dict{Symbol})
8886 end
8987end
9088
89+ function _symbolic_evaluate_helper (expr, syms:: Dict )
90+ if (res = get (syms, expr, nothing )) != = nothing
91+ return res
92+ end
93+ expr isa Expr || return expr
94+
95+ newexpr = Expr (expr. head)
96+ sizehint! (newexpr. args, length (expr. args))
97+ for arg in expr. args
98+ push! (newexpr. args, _symbolic_evaluate_helper (arg, syms))
99+ end
100+ newexpr
101+ end
102+
91103# ########### IsTimeseriesTrait
92104
93105abstract type IsTimeseriesTrait end
0 commit comments