0

Suppose racket's datalog code:

#lang datalog

price(a, 1).
a1(A) :- price(A, Price), Price > 0.
a1(A)?

I would expect result:

a1(a)

I receive an error:

prices_datalog.rkt:4:32: datalog: Unexpected token IDENTIFIER in: ">"

How can I solve this problem?

Jaro
  • 3,799
  • 5
  • 31
  • 47

1 Answers1

1

it looks like it is not directly supported. But you can define your own operator.

#lang datalog/sexp

(! (:- (gt X Y)
       (> X Y :- #t)))  

(! (price a 1))
(! (price b 2))
(! (price c 3))
(! (price d 4))

(! (:- (a2 X)
       (price X Y)
       (gt Y 2)))

(? (a2 X))

;; outputs
a2(c).
a2(d).
Ondrej
  • 503
  • 3
  • 21