A Neat Pattern With Juxt

I recently added the function juxt to my toolbox in Clojure.

A good pattern I've discovered is using juxt to perform operations on a data structure and destructuring its return value.

(defn read-files
  [^String path]
  (let [data-files (find-data-files path)
        [prices receipts] ((juxt find-prices-file find-receipt-files) data-files)]
    {:prices (read-prices prices)
     :receipts (apply merge (read-receipts receipts))}))

Join the 80/20 DevOps Newsletter

If you're an engineering leader or developer, you should subscribe to my 80/20 DevOps Newsletter. Give me 1 minute of your day, and I'll teach you essential DevOps skills. I cover topics like Kubernetes, AWS, Infrastructure as Code, and more.

Not sure yet? Check out the archive.

Unsubscribe at any time.