Skip to content

Commit

Permalink
* src/main/clojure/clojure/core/logic/arithmetic.clj: consolidate int…
Browse files Browse the repository at this point in the history
…o clojure.core.logic
  • Loading branch information
swannodette committed Nov 2, 2011
1 parent 8d3d604 commit c0e2f58
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 2,058 deletions.
4 changes: 1 addition & 3 deletions src/main/clojure/clojure/core/logic/arithmetic.clj
@@ -1,8 +1,6 @@
(ns clojure.core.logic.arithmetic
(:refer-clojure :exclude [reify == inc = > < >= <=])
(:use clojure.core.logic.minikanren
[clojure.core.logic.nonrel :only [project]])
(:import [clojure.core.logic.minikanren Substitutions]))
(:use clojure.core.logic))

(defmacro = [x y]
"Goal for testing whether x and y are equal. Non-relational."
Expand Down
28 changes: 7 additions & 21 deletions src/main/clojure/clojure/core/logic/bench.clj
@@ -1,10 +1,7 @@
(ns clojure.core.logic.bench
(:refer-clojure :exclude [reify inc ==])
(:use clojure.core.logic.minikanren
[clojure.core.logic.prelude :only [defne membero appendo]]
[clojure.core.logic.disequality :only [!=]])
(:require [clojure.core.logic.nonrel :as nonrel]
[clojure.core.logic.arithmetic :as a]))
(:use clojure.core.logic)
(:require [clojure.core.logic.arithmetic :as a]))

(comment
(run* [q]
Expand Down Expand Up @@ -63,17 +60,6 @@
;; zebra
;; =============================================================================

(defn conso [a d l]
(== (lcons a d) l))

(defn firsto [l a]
(fresh [d]
(conso a d l)))

(defn resto [l d]
(fresh [a]
(== (lcons a d) l)))

(defne righto [x y l]
([_ _ [x y . ?r]])
([_ _ [_ . ?r]] (righto x y ?r)))
Expand Down Expand Up @@ -134,7 +120,7 @@
([_ ()])
([[?x ?y] [[?x1 ?y1] . ?others]]
(!= ?y ?y1)
(nonrel/project [?y ?y1 ?x ?x1]
(project [?y ?y1 ?x ?x1]
(!= (- ?y1 ?y) (- ?x1 ?x))
(!= (- ?y1 ?y) (- ?x ?x1)))
(noattacko [?x ?y] ?others)))
Expand Down Expand Up @@ -204,11 +190,11 @@
(digito o l5 l6)
(digito r l6 l7)
(digito y l7 l8)
(nonrel/project [s e n d m o r y]
(project [s e n d m o r y]
(== ?send (+ (* s 1000) (* e 100) (* n 10) d))
(== ?more (+ (* m 1000) (* o 100) (* r 10) e))
(== ?money (+ (* m 10000) (* o 1000) (* n 100) (* e 10) y))
(nonrel/project [?send ?more]
(project [?send ?more]
(== ?money (+ ?send ?more)))))))

(defn send-money-quicklyo [send more money]
Expand Down Expand Up @@ -243,8 +229,8 @@

(defne partitiono [a b c d]
([[?x . ?l] _ [?x . ?l1] _]
(nonrel/conda
((nonrel/project [?x b]
(conda
((project [?x b]
(== (<= ?x b) true))
(partition ?l b ?l1 d))
(partition ?l b c d))))
9 changes: 4 additions & 5 deletions src/main/clojure/clojure/core/logic/dcg.clj
@@ -1,7 +1,6 @@
(ns clojure.core.logic.dcg
(:refer-clojure :exclude [reify == inc])
(:use [clojure.core.logic minikanren prelude])
(:require [clojure.core.logic.nonrel :as nonrel]))
(:use [clojure.core.logic]))

;; TODO: think about indexing
;; TODO: note that rest args are problematic since we add two invisible args
Expand Down Expand Up @@ -198,7 +197,7 @@
(def-->e digito [x]
([_] [x]
(!dcg
(nonrel/project [x]
(project [x]
(== (contains? digits x) true)))))

(def-->e numo [x]
Expand All @@ -210,7 +209,7 @@
(def-->e symo [x]
([[?a . ?as]] [?a]
(!dcg
(nonrel/project [?a]
(project [?a]
(conde
((== (contains? alpha ?a) true))
((== (contains? nonalnum ?a) true)))))
Expand All @@ -219,7 +218,7 @@
(def-->e symro [x]
([[?a . ?as]] [?a]
(!dcg
(nonrel/project [?a]
(project [?a]
(conde
((== (contains? alnum ?a) true))
((== (contains? nonalnum ?a) true)))))
Expand Down
250 changes: 0 additions & 250 deletions src/main/clojure/clojure/core/logic/disequality.clj

This file was deleted.

0 comments on commit c0e2f58

Please sign in to comment.