Created
July 21, 2011 09:43
-
-
Save dmt/1096869 to your computer and use it in GitHub Desktop.
cond collection type with tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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