|
|||||
Functions: recursive | |||||
Prerequisite Concepts | Related Syntax |
OmniMark functions can be called "recursively". That is, a function can call itself.
Recursion is a "structured" looping technique in which a function calls itself to do a subpart of its work. Recursive techniques are especially useful in "divide-and-conquer" applications such as sorting, where the data being sorted is typically "partitioned" and the sorting algorithm applied recursively to each of the partitions.
For example, the following is an example of a recursive function. This function is used to calculate the "factorial" of the number -- the product of all of the integers up to and including the number specified:
define function factorial (value counter n) as do when n <= 0 return 1 else return n * factorial (n - 1) done
Prerequisite Concepts Functions |
Related Syntax define function |
---- |