如何在惯用clojure方式重复stringn次?
在Ruby中, "str" * 3会给你“strstrstr”。 在Clojure中,我能想到的最接近的是(map (fn [n] "str") (range 3))有没有更习惯性的做法呢? 
这个怎么样?
 (apply str (repeat 3 "str")) 
要不就
 (repeat 3 "str") 
如果你想要一个序列而不是一个string。
还有一个使用协议的好玩的select:
 (defprotocol Multiply (* [this n])) 
接下来是String类的扩展:
 (extend String Multiply {:* (fn [this n] (apply str (repeat n this)))}) 
所以你现在可以“方便”使用:
 (* "foo" 3) 
你也可以使用clojure.contrib.string中的重复函数。 如果您使用require等将它添加到您的名称空间中
 (ns myns.core (:require [clojure.contrib.string :as str])) 
然后
 (str/repeat 3 "hello") 
会给你
 "hellohellohello" 
只是为了抛出一些更棒的,有希望的发人深思的解决scheme。
 user=> (clojure.string/join (repeat 3 "str")) "strstrstr" user=> (format "%1$s%1$s%1$s" "str") "strstrstr" user=> (reduce str (take 3 (cycle ["str"]))) "strstrstr" user=> (reduce str (repeat 3 "str")) "strstrstr" user=> (reduce #(.concat %1 %2) (repeat 3 "str")) "strstrstr" 
或者使用clojure-contrib string包中的重复函数。 在这种情况下,你可以使用(clojure.contrib.string / repeat 3“str”),这会导致“strstrstr”。
单一的解决scheme:(即:不要这样做 )
((fn [[xs]](apply(eval x)xs))(重复4'str))