That is to normal way to do it, except that your definition > ff(i::Int) = f2(i::Int) is not necessary.
Just do julia> func(f2) 20.0 julia> func(f1) 40.0 Functions can just be passed around with their name, just like any other variable. The difference only comes once you add the `(...)` to it, which then evaluates the function. On Mon, 2014-06-09 at 07:06, [email protected] wrote: > Tried the following way and it worked. Wonder if anyone would comment on > its properness? > > ------------------------ > function f1(i::Int) > x = 10. * i > println(x) > nothing > end > > function f2(i::Int) > x = 5. * i > println(x) > nothing > end > > function func(ff) > ff(4) > end > > ff(i::Int) = f2(i::Int) > > func(ff) > > On 06/09/2014 01:34 PM, cnbiz850 wrote: >> Say I want to pass the following function f1 to a function called f2 >> as an argument. What is exactly the type of function f1? How do I >> define f2's arguments? >> >> function f1(i::Int, x::Float) >> x = 10. * i >> nothing >> end >> >> function f2(f1::???) >> end
