Seven More Languages in Seven Weeks (读书笔记):miniKaren

miniKaren

  1. Day 1
    1. $ lein new logical //从Clojure boost?
    2. user=> (use 'clojure.core.logic)
    3. user=> (run* [q] (== q 1))
    4. user=> (run* [q] (membero q [1 2 3])) //默认返回所有可能的答案
      1. user=> (run 2 [q] (membero q [1 2 3])) //限制答案个数?
    5. user=> (run 5 [q] (membero [1 2 3] q)) //What the Fuck?backward倒推?
    6. user=> (use 'clojure.core.logic.pldb)
      1. ...
      2. (with-db facts (run* [q] (womano q)))
    7. 并行宇宙:conde
    8. 定义关系:conso
    9. 编写`insideo`
  2. Day 2
    1. 重写matche:
      1. (defn insideo [e l] (matche [l]
        ([ [e . _] ])
        ([ [_ . t] ] (insideo e t))))
    2. defne:模式作为输入
    3. 再次重写matche:
      1. (defne insideo [e l]
        ([_ [e . _]])
        ([_ [_ . t]] (insideo e t)))
    4. Maps in core.logic work mostly as they do in Clojure.
      1. featurec(Map必须满足一个约束)
    5. conda与condu
      1. conda only looks for solutions in the first branch that has a successful first goal
      2. condu:不限于第一个分支,找到一个答案后完全停止(但是实际的搜索是多线程执行吗?)
  3. Day 3
    1. Programming with Finite Domains
      1. (run* [q]
        (fd/in q (fd/interval 0 10)) ❶
        (fd/<= q 1))
    2. ?Strange Loop 2013. “Linear Logic Programming” by Chris Martens

你可能感兴趣的:(clojure,逻辑编程,miniKaren,关系编程,core.logic)