@@ -7,7 +7,8 @@ export toexpr, Assignment, (←), Let, Func, DestructuredArgs, LiteralExpr,
77 SpawnFetch, Multithreaded
88
99import .. SymbolicUtils
10- import SymbolicUtils: @matchable , Sym, Term, istree, operation, arguments
10+ import SymbolicUtils: @matchable , Sym, Term, istree, operation, arguments,
11+ symtype
1112
1213# #== state management ==##
1314
@@ -98,6 +99,20 @@ toexpr(a::Assignment, st) = :($(toexpr(a.lhs, st)) = $(toexpr(a.rhs, st)))
9899
99100function_to_expr (op, args, st) = nothing
100101
102+ function function_to_expr (op:: Union{typeof(*),typeof(+)} , O, st)
103+ args = map (toexpr, arguments (O))
104+ if length (args) >= 3 && symtype (O) <: Number
105+ x, xs = Iterators. peel (args)
106+ foldl (xs, init= x) do a, b
107+ Expr (:call , op, a, b)
108+ end
109+ else
110+ expr = Expr (:call , op)
111+ append! (expr. args, args)
112+ expr
113+ end
114+ end
115+
101116function function_to_expr (:: typeof (^ ), O, st)
102117 args = arguments (O)
103118 if length (args) == 2 && args[2 ] isa Real && args[2 ] < 0
0 commit comments