-
Notifications
You must be signed in to change notification settings - Fork 132
/
misc.clj
40 lines (29 loc) · 976 Bytes
/
misc.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(ns jonase.kibit.rules.misc)
(def rules
'{;; 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 #(not (?pred ?x)) ?coll) (remove ?pred ?coll)
;; Unneeded anonymous functions -- see bug #16
;; (fn ?args (?fun . ?args)) ?fun
;; (fn* ?args (?fun . ?args)) ?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)})
(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]))