Clojure – disj

Clojure disj

In this guide, we will discuss Clojure disj. Disjoins an element from the set.

Syntax

Following is the syntax.

(disj setofelements x)

Parameters − ‘setofelements’ is the set of elements. ‘x’ is the element which needs to be removed from the set.

Return Value − Returns the new set with the removed element.

Example

Following is an example of disj in Clojure.

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (disj (set '(3 2 1)) 2)))
(example)

Output

The above code produces the following output.

#{1 3}

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply