-
Notifications
You must be signed in to change notification settings - Fork 5
5) Inline Predicates and Calling Predicates
One can define and call a predicate directly inside another predicate using curvy brackets {...}
. For example:
predicate0{predicate1}
predicate2
...
As you can see, since the inline predicate appears before the predicate on the second line, it has a smaller index.
Multiple rules can be written inside an inline predicate just like normal predicates. Inline predicates can contain other inline predicates.
An inline predicate will be queried with the variable to the left of the opening {
as Input and the variable to the right of the closing }
as Output.
The main predicate is the one you query to run your program. To call other predicates, you must use the built-in predicate ↰ - Call predicate
. The subscript of ↰
is the number of the predicate you want to call (default: recursive call).
The output of the predicate you called will be unified with the output of ↰
.