我是Clojure的新手。我正在定義一個包含字符串值的向量。要求是從輸入向量中檢索用逗號分隔的字符串值。例如:逗號分隔的字符串值來自一個Vector
(def my-strings ["one" "two" "three"])
我的預期輸出應該是:
"one", "two", "three"
我試圖interpose
和join
,如下圖所示:
(apply str (interpose "," my-strings))
(clojure.string/join "," my-strings)
兩個返回"one,two,three"
但我需要用雙包圍的字符串引用""
就像我上面的例子。
字符文字也是允許的「%\」)my-strings)...' –
@ A.Webb看起來更好,我編輯了我的答案。謝謝:) –
引用換行也恰好是字符串對象打印機的行爲:'(clojure.string/join「,」(map pr-str my-strings))''。 –