Clojure - Sequences concat


Advertisements

This is used to concat two sequences together.

Syntax

Following is the syntax.

(concat seq1 seq2)

Parameters − ‘seq1’ is the first sequence list of elements. ‘seq2’ is the second sequence list of elements, which needs to be appended to the first.

Return Value − The combined sequence of elements.

Example

Following is an example of concat in Clojure.

(ns clojure.examples.example
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def seq1 (seq [1 2]))
   (def seq2 (seq [3 4]))
   (println (concat seq1 seq2)))
(Example)

Output

The above program produces the following output.

(1 2 3 4)
clojure_sequences.htm
Advertisements