To call a function with argument value , one can write either
f(x)or
f * xIn other words, you can view "f of x" as "multiply x by f". Conversely, whenever A * B is defined, one can use A like a function.
If f takes more than one input argument, one can either call the function with the correct number of arguments, or call it with a single argument, which is a list whose length is equal to the number of input arguments of the function definition. For example
f = (x, y, alpha) -> (x^alpha + y^alpha)^(1 / alpha); s = (3, 4, 2); f(s) // equivalent to f(3, 4, 2), and f * s as well
On the other hand, if the function definition has only one input argument, it's still possible to call it with more than one actual arguments, in which case, the arguments will be wrapped as a list and the list is passed to the function. This provides a simple way to implement variant argument list.
f = function x -> s s = 0; for k = 1 : #x s += x # k; end end f(2, 3, 5, 7, 11) 28
In general, no matter how the function f is defined, the signature can be represented as f = function x -> y, where x and/or y can be single variable, list of variable, or empty list.
oz 2009-12-22