There may be a slicker way to do this, but this should work:

julia> fngen(expr,fn) = eval(parse(string(fn)* "=" * string(expr)))
fngen (generic function with 1 method)

julia> expr = :(x + y)
:(x + y)

julia> fngen(expr,:(f(x,y)))
func (generic function with 1 method)

julia> f(2,2)
4

On Thursday, October 22, 2015 at 11:10:09 AM UTC-5, Jānis Erdmanis wrote:
>
> I am implementing boundary element method with curved elements. As it is 
> daunting task to evaluate derivatives I thought about using `Calculus` 
> symbolic differentiation which as output gives expression. Now I need to 
> convert this expression to a function, but how can I do it?
>
> As an example consider
> expr = :(x + y)
> how can I convert it to the function?
> function f(x,y)
>     # Some magic here
> end
>
>
>

Reply via email to