A set is a data structure that stores data in an unsorted manner. It contains a collection of unique data values.
A get method returns the selected element of a set.
(get setofelements element)
The get method receives two parameters:
setofelement
: the setelement
: the elementThe get
method returns an element from the set.
(ns clojure.examples.example(:gen-class))(defn gett [](println (get (set '(4 6 8)) 4))(println (get (set '(3 2 1)) 1)))(gett)
From the code above:
Line 3: We define a function gett
.
Line 4: We print the element returned using the println
. The get
method is used to get data value 4
from the set
.
Line 5: We print the element returned using the println
. The get
method is used to get data value 1
from the set
.
Line 6: We call the gett
function.