update readme examples
This commit is contained in:
parent
67e8680602
commit
e6451ba33b
1 changed files with 2 additions and 12 deletions
14
README.md
14
README.md
|
|
@ -18,17 +18,7 @@ Consider these examples:
|
||||||
:b [{:dd 4}]})
|
:b [{:dd 4}]})
|
||||||
|
|
||||||
;; Manual Clojure
|
;; Manual Clojure
|
||||||
(defn map-vals [m afn]
|
(update-vals data (fn [vals] (map #(update-vals % inc) vals)))
|
||||||
(->> m (map (fn [[k v]] [k (afn v)])) (into (empty m))))
|
|
||||||
|
|
||||||
(map-vals data
|
|
||||||
(fn [v]
|
|
||||||
(mapv
|
|
||||||
(fn [m]
|
|
||||||
(map-vals
|
|
||||||
m
|
|
||||||
(fn [v] (if (even? v) (inc v) v))))
|
|
||||||
v)))
|
|
||||||
|
|
||||||
;; Specter
|
;; Specter
|
||||||
(transform [MAP-VALS ALL MAP-VALS even?] inc data)
|
(transform [MAP-VALS ALL MAP-VALS even?] inc data)
|
||||||
|
|
@ -40,7 +30,7 @@ Consider these examples:
|
||||||
(def data {:a [1 2 3]})
|
(def data {:a [1 2 3]})
|
||||||
|
|
||||||
;; Manual Clojure
|
;; Manual Clojure
|
||||||
(update data :a (fn [v] (into (if v v []) [4 5])))
|
(update data :a concat [4 5])
|
||||||
|
|
||||||
;; Specter
|
;; Specter
|
||||||
(setval [:a END] [4 5] data)
|
(setval [:a END] [4 5] data)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue