Skip to content

Instantly share code, notes, and snippets.

@mnzk
Created May 27, 2012 06:23
Show Gist options
  • Save mnzk/2802396 to your computer and use it in GitHub Desktop.
Save mnzk/2802396 to your computer and use it in GitHub Desktop.
make-coll.clj
(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