Skip to content

Instantly share code, notes, and snippets.

@hiredman
Created August 14, 2010 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hiredman/524109 to your computer and use it in GitHub Desktop.
Save hiredman/524109 to your computer and use it in GitHub Desktop.
(defmacro fork [x & bodies]
(let [n (gensym)]
`(let [~n ~x]
(pvalues
~@(map (fn [[a & b]]
(cons a (cons n b)))
bodies)))))
(defn join [results fn]
(fn results))
;;=> (-> {:a "foo" :b "bar"}
;; (fork
;; (-> (assoc :b 8))
;; (-> (assoc :y 6))
;; (-> (assoc :x 4)))
;; (join (partial apply merge)))
;;
;; {:x 4, :y 6, :a "foo", :b "bar"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment