Skip to content

Commit

Permalink
Refactored out the equality rules into a new rule set
Browse files Browse the repository at this point in the history
  • Loading branch information
ohpauleez committed Mar 19, 2012
1 parent ce6aec0 commit 8adf570
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/jonase/kibit/rules/arithmetic.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@
[(+ 1 ?x) (inc ?x)]
[(- ?x 1) (dec ?x)]

[(= 0 ?x) (zero? ?x)]
[(= ?x 0) (zero? ?x)]
[(== 0 ?x) (zero? ?x)]
[(== ?x 0) (zero? ?x)]

[(< 0 ?x) (pos? ?x)]
[(> ?x 0) (pos? ?x)]
[(<= 1 ?x) (pos? ?x)]

[(< ?x 0) (neg? ?x)]

[(= ?x ?x) true]
[(== ?x ?x) true]
[(zero? 0) true]

[(* ?x (* . ?xs)) (* ?x . ?xs)]
[(+ ?x (+ . ?xs)) (+ ?x . ?xs)])


23 changes: 23 additions & 0 deletions src/jonase/kibit/rules/equality.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(ns jonase.kibit.rules.equality
(:use [jonase.kibit.rules.util :only [defrules]]))

(defrules rules
;; not=
[(not (= . ?args)) (not= . ?args)]

;; zero?
[(= 0 ?x) (zero? ?x)]
[(= ?x 0) (zero? ?x)]
[(== 0 ?x) (zero? ?x)]
[(== ?x 0) (zero? ?x)]

[(< 0 ?x) (pos? ?x)]
[(> ?x 0) (pos? ?x)]
[(<= 1 ?x) (pos? ?x)]

[(< ?x 0) (neg? ?x)]

[(= ?x ?x) true]
[(== ?x ?x) true]
[(zero? 0) true])

0 comments on commit 8adf570

Please sign in to comment.