|
From: Ethan M. <eam...@gm...> - 2018-04-09 15:58:22
|
On Mon, Apr 9, 2018 at 8:15 AM, Patrick Dupre <pd...@gm...> wrote:
> Hello,
>
> Can I pass a pointer on a function in the argument list of another
> function?
>
Sure. That's what you were doing anyway, whether you knew it or not.
f1(x) = expression_A
f2(x) = expression_B
g(x) = f1(x) * f2(x)
The function g(x) is not expanded to (expression_A*expression_B) at the time
you define it. It is defined in terms of calls to two other named
functions.
When you evaluate g(x) at some future time, it will look up the definitions
of f1 and f2 _at that future time_ in order to perform the evaluation.
So in another notational system (not gnuplot's) you might write that same
definition of g as
g(f1,f2,x) = f1(x) * f2(x)
to make it clearer that f1 and f2 may change between invocations of g().
Does that answer the question?
|