Created
May 27, 2012 06:23
-
-
Save mnzk/2802396 to your computer and use it in GitHub Desktop.
make-coll.clj
This file contains hidden or 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 make-coll | |
[c n init] | |
(let [s (repeat n init)] | |
(if (instance? String c) | |
(apply str s) | |
(into (empty c) s)))) | |
(make-coll [] 5 'a) ;=> [a a a a a] | |
(make-coll '() 5 'a) ;=> (a a a a a) | |
(make-coll "" 5 'a) ;=> "aaaaa" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment