clojuredesign-podcast

Discussions around the Functional Design in Clojure podcast - https://clojuredesign.club/
2020-07-16T21:24:15.112300Z

Just finished juxt. It's one of my favorites. Perhaps my favorite use is computing the coordinates on a unit circle given an input in radians:

(def unit-coordinates (juxt #(Math/cos %) #(Math/sin %)))
I hadn't thought of using juxt for map-vals before:
(defn map-vals [f m]
  (->> m
       (map (juxt key (comp f val)))
       (into (empty m))))

(map-vals inc {:a 1 :b 2})
=> {:a 2, :b 3}
I've always used zipmap but that breaks up your thread-last form. This allows you to keep the thread rolling. Cool!

1
2020-07-16T21:24:50.113Z

I see myself using the latter more. The former is cool, but I don't finding myself doing geometry as much as I'd like.