contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
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
 
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:00:48 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.