Clojure – get

Clojure get

In this guide, we will discuss Clojure get. Returns the element at the index position.

Syntax

Following is the syntax.

(get setofelements index)

Parameters − ‘setofelements’ is the set of elements. ‘index’ is the element at the index position, which needs to be returned.

Return Value − The value of the element at the index position.

Example

Following is an example of get in Clojure.

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

Output

The above code produces the following output.

2
1

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply