A few rules
This commit is contained in:
parent
370a0829d1
commit
deb7fbac24
2 changed files with 11 additions and 4 deletions
|
@ -10,7 +10,8 @@
|
|||
(when true . ?x) (do . ?x)
|
||||
(do ?x) ?x
|
||||
(when-not true ?x) "removing this dead code"
|
||||
(when false ?x) "removing this dead code"})
|
||||
(when false ?x) "removing this dead code"
|
||||
(if-let ?binding ?expr nil) (when-let ?binding ?expr)})
|
||||
|
||||
(comment
|
||||
(when true
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
(ns jonase.kibit.rules.misc)
|
||||
|
||||
(def rules
|
||||
'{(apply str (interpose ?x ?y)) (clojure.string/join ?x ?y)
|
||||
'{;; 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)
|
||||
|
@ -11,14 +13,18 @@
|
|||
(filter (complement ?pred) ?coll) (remove ?pred ?coll)
|
||||
(filter #(not (?pred ?x)) ?coll) (remove ?pred ?coll)
|
||||
|
||||
;; Unneeded anonymous functions
|
||||
(fn ?args (?fun . ?args)) ?fun
|
||||
(fn* ?args (?fun . ?args)) ?fun
|
||||
|
||||
})
|
||||
;; Java stuff
|
||||
(.toString ?x) (str ?x)})
|
||||
|
||||
(comment
|
||||
(apply concat (apply map f (apply str (interpose \, "Hello"))))
|
||||
(filter (complement nil?) [1 2 3])
|
||||
|
||||
(.toString (apply str (reverse "Hello")))
|
||||
|
||||
(map (fn [x] (inc x)) [1 2 3])
|
||||
(map #(dec %) [1 2 3]))
|
||||
|
|
Loading…
Reference in a new issue