How to repeat string n times in idiomatic clojure way?

前端 未结 7 2237
无人及你
无人及你 2020-12-15 16:13

In Ruby, \"str\" * 3 will give you \"strstrstr\". In Clojure, the closest I can think of is (map (fn [n] \"str\") (range 3)) Is there a more idioma

7条回答
  •  感情败类
    2020-12-15 16:55

    Or use the repeat function that comes with clojure-contrib' string package. In that case you can use (clojure.contrib.string/repeat 3 "str") which results in "strstrstr".

提交回复
热议问题