Julia - Defining a function that outputs a function
<p>I'm trying to create a small function to define the Hamiltonian flow if inputted the functions the Hamiltonian consists of. E.g. I would like to define</p>

<pre><code>function makeThedH(f::Function,g::Function)

dH1(s,u) = cos(u[3]).*f(u[1],u[2]);
dH2(s,u) = sin(u[3]).*f(u[1],u[2]);
dH3(s,u) = dot( [1,2] , g(u[1],u[2]) ).*f(u[1],u[2]).^0.5 ;
dH4(s,u) = dot( [1,2] , g(u[1],u[2]) );
dH(s,u) = [dH1(s,u), dH2(s,u), dH3(s,u),dH4(s,u)];
return dH;

end
</code></pre>

<p>to give be a function dH that I could use in an ODE solver. (Forget whether or not that system is well defined or anything). </p>

<p>Can't seem to find any documentation for functions outputting other functions like this. Thank you for any help ~</p>

<p>Edit: It does return a dH, but I can't seem to use it like a normal function e.g. dH(1,[1,2,3,4]) just returns the object (I think?) dH but doesn't evaluate anything.</p>

<p>Edit: Thanks for helping me realize I should put in the input types, that I would like f,g to be function handles.</p>