Skip to content

Instantly share code, notes, and snippets.

@alexy
Forked from arohner/gist:351238
Created April 1, 2010 02:24
Show Gist options
  • Save alexy/351243 to your computer and use it in GitHub Desktop.
Save alexy/351243 to your computer and use it in GitHub Desktop.
(defn map-same
"like map, but returns a collection of the same type as the first input collection"
[f & colls]
(let [first-coll (first colls)]
(if (list? first-coll)
(list* (apply map f colls))
(into (empty first-coll) (apply map f colls)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment