Skip to content

Instantly share code, notes, and snippets.

@astoddard
Forked from jaycfields/gist:3796964
Created September 28, 2012 13:33
Show Gist options
  • Save astoddard/3799887 to your computer and use it in GitHub Desktop.
Save astoddard/3799887 to your computer and use it in GitHub Desktop.
less dry, easier to digest
(-> [jay john mike chris]
(->> (filter (comp (partial = "new york") :current-city)))
(->> (group-by :employer))
(update-in ["drw.com"] (partial map :name)))
@marxama
Copy link

marxama commented Sep 28, 2012

Nifty! I've bumped into the same issue before, and came up with a small, not that clever but occasionally useful macro:

(defmacro thr
  "Like the threading macros, but lets you provide a symbol to which the result
   of each successive form will be bound before calling the next. Example:

   (thr x value
     (fn1 :a :b x :c)
     (fn2 x :x :y x)
     (for [v x] (fn3 v)))" 
  ([sym x form]
    `(let [~sym ~x] 
       ~form))
  ([sym x form & more]
    `(thr ~sym (thr ~sym ~x ~form) ~@more)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment