You could define your own feval:

feval(fn_str, args...) = eval(parse(fn_str))(args...)

This has the advantage of accepting anonymous functions and multiple 
arguments if necessary:
julia> feval("sin",5.0)
-0.9589242746631385

julia> fn_str = "a_plus_b(a,b) = a + b"
"a_plus_b(a,b) = a + b"

julia> feval(fn_str,2,3)
5

On Thursday, October 22, 2015 at 8:20:33 AM UTC-5, J Luis wrote:
>
> Thanks, at least it's a place to start.
>
> quinta-feira, 22 de Outubro de 2015 às 14:10:44 UTC+1, Kristoffer Carlsson 
> escreveu:
>>
>> Maybe
>>
>> julia> eval(Symbol("sin"))(5.0)
>> -0.9589242746631385
>>
>> Not sure if this is the best solution.
>>
>>
>> On Thursday, October 22, 2015 at 2:57:31 PM UTC+2, J Luis wrote:
>>>
>>> Hi,
>>>
>>> I need to convert this piece of Matlab code
>>>
>>>           [ps, orig_path] = feval(str2func(test), out_path);
>>>
>>> where 'test' is the name of a function and 'out_path' it unique input 
>>> argument. I have read and re-read the eval function and for once it's clear 
>>> for me how it works (sorry, I find this sentence highly cryptic "Evaluate 
>>> an expression in the given module and return the result" ) but worst, I 
>>> don't see anywhere how it could call a function with input arguments.
>>>
>>> How can I achieve the same result in Julia?
>>>  
>>> Thanks. 
>>>
>>

Reply via email to