The approaches that occur to me immediately are that you can either
explicitly pass state or use a closure that closes over the state you need
to update. Another option would be to represent your function as an object
and use a generic function to apply that object to its argument.


On Fri, Aug 15, 2014 at 2:20 PM, Neal Becker <[email protected]> wrote:

> I'm trying to do numerical integration.  I want a function that has state
> information.
>
> Let's say I'm trying to integrate some function F over x.  In addition, F
> has
> some state
>
> function F (x, state) = <do something with x and state>
>
> In python (and in c++), one way is to make F a class (which can have
> state), and
> overload the function call operator.  Then this can be passed to the
> numerical
> integrator.
>
> But in julia, we can't overload the function call operator, so I don't
> know how
> to proceed.  Essentially, what we need is to transform the function F by
> binding
> one of it's arguments.
>
> What would you suggest here?
>
>

Reply via email to