Clojure – Vectors conj

Clojure vectors conj

In this guide, we will discuss Clojure Vectors conj. Appends an element to the vector and returns the new set of vector elements.

Syntax

Following is the syntax.

(conj vec x)

Parameters − ‘vec’ is the vector set of elements. ‘x’ is the element which needs to be appended to the set of elements in the vector.

Return Value − Returns the new vector with the appended element.

Example

Following is an example of conj in Clojure.

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (conj (vector 3 2 1) 5)))
(example)

Output

The above code produces the following output.

[3 2 1 5]

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply