Recursion
Syntax
	$start.recursion($fun)
$start.recursion($fun, $min-depth, $max-depth)
  Description
Creates a list by applying the function fun to each element of the set start and recursively to all its function results. The recursion ends when the function null, or a previous result is regenerated. Only the elements resulting from recursion depths between min-depth (inclusive) and max-depth (exclusive) are returned in the evaluation result.
Parameter
| Name | Type | Description | Mandatory | Default | 
|---|---|---|---|---|
| start | number/string/boolean/business object/set | The start value, or the start values of the recursion if specified in a set. | yes | |
| fun | Function | A function to be executed recursively on startand the resulting results. | yes | |
| min-depth | Number | The minimum recursion depth (inclusive). | no | 0 | 
| max-depth | Number | The maximum recursion depth (exclusive). | no | -1 (infinite) | 
Return value
Type: Set
A set consisting of start and all function results from a minimum to a maximum recursion depth.
Examples
Count up
	1.recursion(x -> $x + 1, 0, 9)
  Output: A set with values [1, 2, 3, 4, 5, 6, 7, 8, 9].
Starting from 1, the function that increments a value by 1 is applied 9 times. All results are returned in the result list.
Note: The same result can be achieved much easier and more efficiently using the expression count(1, 10), see Count.
Paths
	$x.recursion(node -> $node.get(`my:Type#parent`), 1)
  Output: The path starting from an element in the variable x to the root of a tree along the parent attribute my:Type#parent.
The path starts with the direct parent of x. The value of x is not itself included in the path because the minimum depth (number of function applications) is set to 1.