Thanks for this answer. It works nicely. I will take my time to
understand it thoroughly.
Le 12/11/2016 à 16:27, Alexander Burger a écrit :
(be underage (@X)
(age @X @Y)
(< @Y 18))
'<' is a Lisp function and not a Pilog rule. To embed a Lisp expression
in Pilog, you must use the '^' operator. It causes the rest of the
expression to be taken as Lisp, and inside the Lisp code you can in turn
access Pilog-bindings with the '->' function.
In the case above it should be something like
(^ @ (< (-> @Y) 18))
'@' is an anonymous variable here. If you want to bind the result of the
Lisp expression to a specific variable, it would be e.g.
(^ @X (+ (-> @N) 7))
This binds @X to @N + 7.
Of course, if you need '<' more often, you could define your own
: (be < (@A @B)
(^ @ (< (-> @A) (-> @B))) )
: (? (< 3 4))
: (? (< 4 2))