Skip to content

Commit b1cbf01

Browse files
authored
Add methods to convert Operation to Expr
1 parent 870f80f commit b1cbf01

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/operations.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ Base.convert(::Type{Operation}, x::Number) = Operation(identity, Expression[Cons
6363
Base.convert(::Type{Operation}, x::Operation) = x
6464
Base.convert(::Type{Operation}, x::Expression) = Operation(identity, Expression[x])
6565
Operation(x) = convert(Operation, x)
66+
67+
#convert to Expr
68+
Base.Expr(op::Operation) =
69+
op.op isa Variable ? op.op.name : Expr(:call, Symbol(op.op), Expr.(op.args)...)
70+
Base.convert(::Type{Expr},x::Operation) = Expr(x)
71+
end

0 commit comments

Comments
 (0)