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}
clojure_sets.htm
Advertisements