Re: [julia-users] Re: How to feval?

2015-10-22 Thread J Luis
Speed is not critical here. I am porting this script http://gmt.soest.hawaii.edu/projects/gmt-matlab-octave-api/repository/changes/trunk/src/gmtest.m that will call the test scripts that live, as for example, here

Re: [julia-users] Re: How to feval?

2015-10-22 Thread Stefan Karpinski
This will not be fast. It's also wildly insecure if the string come from an external source. I'd strongly recommend figuring out a different approach to what you're doing, but it's hard to provide guidance without more context. On Thu, Oct 22, 2015 at 12:34 PM, Alex Ames

Re: [julia-users] Re: How to feval?

2015-10-22 Thread J Luis
Anyway, unfortunately none of the above solutions work for files. If the file is called "GMT_insert.jl", and is in the path, I get variations around (+ file extension - file extension) of ERROR: UndefVarError: GMT_insert not defined quinta-feira, 22 de Outubro de 2015 às 18:30:04 UTC+1, J

Re: [julia-users] Re: How to feval?

2015-10-22 Thread Stefan Karpinski
Julia doesn't identify functions and files the way Matlab does. You can just load the file by name. On Thu, Oct 22, 2015 at 2:56 PM, J Luis wrote: > Anyway, unfortunately none of the above solutions work for files. If the > file is called "GMT_insert.jl", and is in the path,

[julia-users] Re: How to feval?

2015-10-22 Thread J Luis
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

[julia-users] Re: How to feval?

2015-10-22 Thread Alex Ames
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"