up previous next
func    --    Anonymous function


Syntax
Func(ARGS) BODY EndFunc
  returns FUNCTION

Description
This syntatic structure defines an anonymous function, i.e. a function without a name. Anonymous functions can be passed as parameters, assigned to variables, and returned as values.

To access variables outside the anonymous function use the commands ImportByRef, ImportByValue or TopLevel .

Example
/**/  square := Func(x) Return x^2; EndFunc;
/**/  square(3);
9

/**/  strings := ["x", "zzz", "yy"];
/**/  SortedBy(strings, Func(x,y) return len(x)>len(y); EndFunc);
["zzz", "yy", "x"]

See Also