Clojure - 字串連線



返回集合中所有元素的字串,由 (seq collection) 返回,並用可選的分隔符分隔。

語法

以下是語法。

(join sep col)

引數 − ‘sep’ 是集合中每個元素的分隔符。‘col’ 是元素的集合。

返回值 − 連線後的字串。

示例

以下是 Clojure 中 join 的示例。

(ns clojure.examples.hello
   (:gen-class))
(defn hello-world []
   (println (clojure.string/join ", " [1 2 3])))
(hello-world)

輸出

以上程式產生以下輸出。

1 , 2 , 3
clojure_strings.htm
廣告