Clojure - Strings join



Returns a string of all elements in collection, as returned by (seq collection), separated by an optional separator.

Syntax

Following is the syntax.

(join sep col)

Parameters − ‘sep’ is the separator for each element in the collection. ‘col’ is the collection of elements.

Return Value − A joined string.

Example

Following is an example of join in Clojure.

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

Output

The above program produces the following output.

1 , 2 , 3
clojure_strings.htm
Advertisements