Fork me on GitHub
#clojuredesign-podcast
<
2020-07-16
>
markbastian21:07:15

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!

clojure-spin 3
markbastian21:07:50

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.