首页 文章

球拍数据记录 - 数据记录与否定?

提问于
浏览

1 回答

  • 1

    这是我能想到的最好的:

    #lang racket
    
    (require datalog)
    
    (define prices (make-theory))
    
    (datalog prices
               (! (price a 1))
               (! (price b 2))
               (! (price c 3))
               (! (price d -5))
               (! (price e 5))
               )
    
    (define (notgt x y)
      (not (> x y)
      ))
    
    (datalog prices
               (! (:- (notgt X Y)
                      (notgt X Y :- #t))
                      ))
    
    (datalog prices
             (! (:- (al2 X)
                    (price X Y)
                    (notgt Y 2)
                    )))
    
    (datalog prices (? (al2 X)))
    

    问题是谓词必须全部返回true并且不能复杂,所以你不能写那些像 (not (= Y 2)) 的东西 . 而且看起来否定不是球拍的数据记录,但我不是这方面的专家 . 在球拍中还有另一个数据记录实现:https://github.com/rntz/datafun但我不知道这是否更好 .

相关问题