mk: phase 2C — conde, the canonical and-or sugar
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
conde.sx is a single defmacro: (conde (g1a g1b ...) (g2a g2b ...) ...) folds to (mk-disj (mk-conj g1a g1b ...) (mk-conj g2a g2b ...) ...). 9 tests cover single/multi-clause, mixed success/failure, conjunction inside clauses, fresh+disj inside a clause, nesting, and all-fail / no-clauses. 100/100 cumulative.
This commit is contained in:
20
lib/minikanren/conde.sx
Normal file
20
lib/minikanren/conde.sx
Normal file
@@ -0,0 +1,20 @@
|
||||
;; lib/minikanren/conde.sx — Phase 2 piece C: `conde`, the canonical
|
||||
;; miniKanren and-or form.
|
||||
;;
|
||||
;; (conde (g1a g1b ...) (g2a g2b ...) ...)
|
||||
;; ≡ (mk-disj (mk-conj g1a g1b ...)
|
||||
;; (mk-conj g2a g2b ...) ...)
|
||||
;;
|
||||
;; Each clause is a list of goals, conj'd internally; clauses are disj'd
|
||||
;; among one another (interleaved via mk-mplus, so left-recursive
|
||||
;; relations don't starve the right-hand clauses).
|
||||
|
||||
(defmacro
|
||||
conde
|
||||
(&rest clauses)
|
||||
(quasiquote
|
||||
(mk-disj
|
||||
(splice-unquote
|
||||
(map
|
||||
(fn (clause) (quasiquote (mk-conj (splice-unquote clause))))
|
||||
clauses)))))
|
||||
Reference in New Issue
Block a user