【问题标题】:Does projecting in two directions count as relational in core.logic?在 core.logic 中,两个方向的投影算作关系吗?
【发布时间】:2013-03-31 06:44:54
【问题描述】:

我了解 core.logic 中的 project 不是关系型。

但是,我似乎可以通过在conda 内的两个方向进行投影来获得类似关系的行为,例如:

(defn lifto-with-inverse
  "Lifts a unary function and its inverse into a core.logic relation."
  ([f g]
    (fn [& vs]
      (let [[x y] vs]
        (conda 
          [(pred x number?) (project [x] (== y (f x)))]
          [(pred y number?) (project [y] (== x (g y)))])))))

(let [inco (lifto-with-inverse inc dec)]
   (run* [q] (inco q 3)))
=> 2

这算作关系操作吗?或者是否缺少其他东西使这与非关系无关?

【问题讨论】:

    标签: clojure logic-programming clojure-core.logic minikanren


    【解决方案1】:

    在这种情况下,似乎其中一个论点必须是基础的,因此它是非关系型的。

    【讨论】:

      猜你喜欢
      • 2013-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      相关资源
      最近更新 更多