Added in new equality rules and removed bad whitespace
This commit is contained in:
parent
8adf570c5a
commit
665d1d2007
3 changed files with 14 additions and 12 deletions
|
@ -5,6 +5,7 @@
|
|||
(:require [jonase.kibit.rules.arithmetic :as arith]
|
||||
[jonase.kibit.rules.control-structures :as control]
|
||||
[jonase.kibit.rules.collections :as coll]
|
||||
[jonase.kibit.rules.equality :as equality]
|
||||
[jonase.kibit.rules.performance :as perf]
|
||||
[jonase.kibit.rules.misc :as misc]))
|
||||
|
||||
|
@ -29,6 +30,7 @@
|
|||
(def rule-map {:control-structures control/rules
|
||||
:arithmetic arith/rules
|
||||
:collections coll/rules
|
||||
:equality equality/rules
|
||||
:perf perf/rules
|
||||
:misc misc/rules})
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
(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)]
|
||||
|
|
|
@ -14,32 +14,32 @@
|
|||
(pred fun not-method?))))
|
||||
|
||||
(defrules rules
|
||||
;; clojure.string
|
||||
;; clojure.string
|
||||
[(apply str (interpose ?x ?y)) (clojure.string/join ?x ?y)]
|
||||
[(apply str (reverse ?x)) (clojure.string/reverse ?x)]
|
||||
|
||||
|
||||
;; mapcat
|
||||
[(apply concat (apply map ?x ?y)) (mapcat ?x ?y)]
|
||||
[(apply concat (map ?x . ?y)) (mapcat ?x . ?y)]
|
||||
|
||||
|
||||
;; filter
|
||||
[(filter (complement ?pred) ?coll) (remove ?pred ?coll)]
|
||||
[(filter (complement ?pred) ?coll) (remove ?pred ?coll)]
|
||||
[(filter #(not (?pred ?x)) ?coll) (remove ?pred ?coll)]
|
||||
|
||||
|
||||
;; Unneeded anonymous functions -- see bug #16
|
||||
[(fn ?args (?fun . ?args)) [fn-call?] ?fun]
|
||||
[(fn* ?args (?fun . ?args)) [fn-call?] ?fun]
|
||||
|
||||
|
||||
;; do
|
||||
[(do ?x) ?x]
|
||||
|
||||
|
||||
;; Java stuff
|
||||
[(.toString ?x) (str ?x)]
|
||||
|
||||
|
||||
;; Threading
|
||||
[(-> ?x ?y) (?y ?x)]
|
||||
[(->> ?x ?y) (?y ?x)]
|
||||
|
||||
|
||||
;; Other
|
||||
[(not (= . ?args)) (not= . ?args)])
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
(filter (complement nil?) [1 2 3])
|
||||
|
||||
(.toString (apply str (reverse "Hello")))
|
||||
|
||||
|
||||
(map (fn [x] (inc x)) [1 2 3])
|
||||
(map (fn [x] (.method x)) [1 2 3])
|
||||
(map #(dec %) [1 2 3])
|
||||
|
|
Loading…
Reference in a new issue