Clojure – Lists conj

Clojure lists conj

In this guide, we will discuss Clojure Lists conj. Returns a new list wherein the list is at the beginning and the elements to be appended are placed at the end.

Syntax

Following is the syntax.

(conj lst elementlst)

Parameters − ‘elementlst’ is the list of items which needs to be added to the list. ‘lst’ is the list of items.

Return Value − The list with the appended values.

Example

Following is an example of cons in Clojure.

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

Output

The above program produces the following output.

(5 4 1 2 3)

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply