Skip to content

Instantly share code, notes, and snippets.

@dmt
Created July 21, 2011 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmt/1096869 to your computer and use it in GitHub Desktop.
Save dmt/1096869 to your computer and use it in GitHub Desktop.
cond collection type with tests
(defn collection-type [col]
(cond (set? col) :set
(map? col) :map
(list? col) :list
(vector? col) :vector
(seq? col) :seq))
(deftest collection-type-returns-correct-name
(is (= :list (collection-type '())))
(is (= :map (collection-type {})))
(is (= :vector (collection-type [])))
(is (= :set (collection-type #{}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment