I want to convert mathematica “expressions” into usable functions, for instance, go from the text “Abs[omega]” to a function f(omega) = abs(omega). I’ve seen this topic, which is helpful as it gives me a Julia expression corresponding to what I want.
However, I don’t know how to go from an “Expr” to a usable function in Julia. For instance, when I do
using SymPy
const sympy_parsing_mathematica = SymPy.PyCall.pyimport("sympy.parsing.mathematica")
mathematica2julia(s::AbstractString, substitutions::Pair{<:AbstractString,<:AbstractString}...) =
SymPy.walk_expression(sympy_parsing_mathematica."mathematica"(s, Dict(substitutions...)))
f = mathematica2julia("Abs[omega]")
I’d like to be able to use f as f(omega), ex. compute (f(-1)). I know this is related to metaprogramming, which I am not familiar with, but even looking at the documentation I couldn’t figure it out.