Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme examples #326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions README.md
Expand Up @@ -18,17 +18,8 @@ Consider these examples:
:b [{:dd 4}]})

;; Manual Clojure
(defn map-vals [m afn]
(->> 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)))
(let [update-even #(update-vals % (fn [v] (cond-> v (even? v) inc)))]
(update-vals data #(mapv update-even %)))

;; Specter
(transform [MAP-VALS ALL MAP-VALS even?] inc data)
Expand All @@ -40,7 +31,7 @@ Consider these examples:
(def data {:a [1 2 3]})

;; Manual Clojure
(update data :a (fn [v] (into (if v v []) [4 5])))
(update data :a concat [4 5])

;; Specter
(setval [:a END] [4 5] data)
Expand Down