There are two forms of function expression. The constructor form has the syntax
func< FORMAL_IDFIER, ..., FORMAL_IDFIER | EXPRESSION >
and the statements form has the syntax
function(FORMAL_IDFIER, ..., FORMAL_IDFIER) STATEMENTS end function
Each of these creates an expression which evaluates to a function. The most common use for a function expression is to assign it to an identifier immediately, but a function can be used as an object in its own right.
// Function expression (recursive) for the n-th Fibonacci number:func< n | n le 2 select 1 else $$(n-1) + $$(n-2) >
// and a direct call to it:
> print func< n | n le 2 select 1 else $$(n-1) + $$(n-2) >(8); 21
Given a real t and a suitable function f at runtime, this function expression will return q^5 + 4*q^3 - 2*Exp(q) + q*t where q=f(t):
function(t, f) q := f(t); return q^5 + 4*q^3 - 2*Exp(q) + q*t; end function
[Next] [Prev] [Right] [____] [Up] [Index] [Root]