Skip to content

How to stop recursion from recursing #16601

Answered by aibaars
Sixelayo asked this question in Q&A
Discussion options

You must be logged in to vote

The evaluation of a predicate in QL does not yield a single return value, instead it returns a set of all possible combinations of parameters and result values for which the predicate "holds".

The evaluation of a recursive predicate in QL is done bottom-up and is quite different from evaluating a recursive function in a more common programming language. The evaluation strategy is roughly as follows: initially the set of answers is empty, evaluate the body of the predicate to find new possible answers, add those to the set and repeat until no new answers are found.

For example

int rec(int i){
    (result = i and i=0)
    or 
    exists(int stop |
        stop = 3
        and i < stop
        

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Sixelayo
Comment options

@aibaars
Comment options

Answer selected by Sixelayo
@aibaars
Comment options

@Sixelayo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants