Invoke
Invokes a function when the function is itself the result of invoking another function.
Syntax
invoke
[function]
· [argument1]
· [argument2]
…
- function
- The function invocation that returns the function to invoke.
- argument1-N
- The arguments to pass to the function.
Example
Suppose there is a function called AddToAll
that takes a number and returns another function that adds this number to every element in a given list, defined this way:
function (number)
function (items)
Core.Map
· items
· function (item)
+
· item
· number
If we wish to add 5 to every item in a list, we could do it using the invoke
keyword:
invoke
AddToAll
· 5
· list
· 10
· 20
· 30
The code above would be equivalent to having a function called Add5ToAll
defined this way:
AddToAll
· 5
And then calling this function like this:
Add5ToAll
· list
· 10
· 20
· 30
Both will produce the list [15 25 35]
as a result.