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