Clojure-strings-join

提供:Dev Guides
移動先:案内検索

Clojure-文字列結合

(seq collection)によって返されるコレクション内のすべての要素のストリングを、オプションのセパレーターで区切って返します。

構文

構文は次のとおりです。

(join sep col)

パラメータ-「sep」はコレクション内の各要素の区切り文字です。 「col」は要素のコレクションです。

戻り値-結合された文字列。

Clojureでの結合の例を次に示します。

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

出力

上記のプログラムは、次の出力を生成します。

1 , 2 , 3