Converting an expression to a function

A way to compile a function from an expression:

  | | |_| | | | (_| |  |  Version 1.5.0 (2020-08-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> ex = :(x + 42)
:(x + 42)

julia> fun = @eval (x) -> $ex
#1 (generic function with 1 method)

julia> fun(10)
52

I was not able to make your example work, so not sure if this helps.

1 Like