In this guide, we will discuss Clojure Vectors nth. This function returns the item in the nth position in the vector.
Syntax
Following is the syntax.
(nth vec index)
Parameters − ‘vec’ is the vector of items. ‘index’ is the index position of the element which needs to be returned.
Return Value − The value at the index position from the vector.
Example
Following is an example of nth in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (println (nth (vector 1 2,3) 0)) (println (nth (vector 1 2,3) 2))) (example)
Output
The above code produces the following output.
1 3
Next Topic : Click Here
Pingback: Clojure - vector-of | Adglob Infosystem Pvt Ltd
Pingback: Clojure - Vectors | Adglob Infosystem Pvt Ltd