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
广告

© . All rights reserved.