Tutorial: Passing a Function, Function callback
Last updated
Was this helpful?
Last updated
Was this helpful?
In this tutorial, we will learn how to pass a mathematical function f(x) as an input argument to another function.
How can you use myfunc()
within the function of gradientFunc()
that finds the derivative?
myFun(x): returns F(x)= 2x^3
gradientFunc(myfunc): returns 6x^2
Example:
There are several methods of calling a function within another function.
Calling the function that is defined globally or in the same scope
Pass a function as an input argument to another function.