Generate a Vector of Identical Items of Length N

Viewed 765

I would like to generate a vector of identical items given the item and a count. This seems like a something that should be easier to do than with a loop. Any ideas of making the function below tighter/streamlined?

;take an object and a nubmer n and return a vector of those objects that is n-long
(defn return_multiple_items [item number-of-items]
    (loop [x 0
           items [] ]
      (if (= x number-of-items)
           items
           (recur (+ x 1)
                  (conj items item)))))

>(return_multiple_items "A" 5 )
>["A" "A" "A" "A" "A"]
>(return_multiple_items {:years 3} 3)
>[{:years 3} {:years 3} {:years 3}]
3 Answers
Related