Not sure that I understand the question, but maybe this helps:
function g1(a,b)
x -> 2*a*b*x
end
function g2(a,b)
x -> 3*a*b*x
end
function my_add(fun1, fun2) # function you asked for
x -> fun1(x)+fun2(x)
end
y = my_add(g1(1,2),g2(1,2))
y(3) # 5*1*2*3=30
Also, note the syntactic difference between anonymous and generic
functions. Your definitions below are all anonymous, assigned to a
variable.
Best,
Tamas
On Sat, Sep 19 2015, Lee Streeter <[email protected]> wrote:
> Hello there
>
> I'm a long time Matlab user and I'm loving using Julia.
>
> Is there a simple way to string together anonymous functions built from
> closures? What I mean is say I have a function
>
> g = function(a,b)
> f=function (x)
> 'some code that returns numerical output based on inputs a and b'
> end
> end
>
> I would like to form
> y = g(a1,b1) + g(a2,b2)
> so I can call
> y(x_numerical_value)
>
>
> While I'm here I'm finding that Gadfly graphs cause a memory leak in Atom
> Helper in Juno on a Mac. All updates installed on the Mac
> and I downloaded the Juno bundle today - so stable everything.
> I'm not sure where in all that is the problem so am not sure where to file
> something.
>
> Thanks, and regards