Skip to content

Instantly share code, notes, and snippets.

@fffej
Created August 5, 2009 20:17
Show Gist options
  • Save fffej/162926 to your computer and use it in GitHub Desktop.
Save fffej/162926 to your computer and use it in GitHub Desktop.
(defmacro accum
[f body]
`(with-local-vars [acc# (transient [])
~f (fn [x#](conj! (var-get acc#) x#))]
~body
(persistent! (var-get acc#))))
(defn my-keys [m] (accum a (doseq [[k v] m] (a k))))
(defn my-vals [m] (accum a (doseq [[k v] m] (a k))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment