This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-10
Channels
- # announcements (14)
- # bangalore-clj (1)
- # beginners (89)
- # calva (166)
- # cider (33)
- # clara (12)
- # clj-kondo (1)
- # cljdoc (8)
- # clojure (101)
- # clojure-austin (1)
- # clojure-colombia (7)
- # clojure-dev (14)
- # clojure-europe (5)
- # clojure-hamburg (10)
- # clojure-italy (9)
- # clojure-nl (31)
- # clojure-spec (4)
- # clojure-uk (39)
- # clojurescript (17)
- # clojutre (3)
- # code-reviews (16)
- # cursive (72)
- # data-science (1)
- # datomic (81)
- # duct (8)
- # emacs (4)
- # figwheel-main (1)
- # graalvm (2)
- # jobs (9)
- # kaocha (21)
- # lambdaisland (2)
- # luminus (4)
- # off-topic (35)
- # re-frame (1)
- # reagent (101)
- # reitit (4)
- # ring-swagger (5)
- # shadow-cljs (17)
- # sql (40)
- # tools-deps (4)
- # vim (28)
(def xform
(comp
(map #(let [{:keys [id location geohash frequency]} %]
{:id id :location (m/pgobject-location->latlng location) :geohash geohash :frequency frequency}))))
Assuming you will use xform in transducer context so you can chain map
calls
(def xform
(comp
(map #(update % :location m/pgobject-location->latlng))
(map #(select-keys % [:id :location :geohash :frequency]))))
This is what confused me still with transducers, how to read the order, i.e., it looks like in that comp form above, stuff is being applied bottom up....(whereas, the natural way of looking at pipelines is top to bottom)...a bit confusing...
not in the scope of transducers https://clojure.org/reference/transducers#_defining_transformations_with_transducers
you are welcome)
And if you donโt need to have maps with listed keys but only with updated location: (map #(update % :location ....))
will give you a transducer )
You can check on map
โs documentation - look for note about one-arity version of map
there's actually a subtle difference, the old version always has all four keys in the output with absent values as nil, whereas delaguardo's version omits absent keys, because of select-keys
@delaguardo works great