Clojure – Vectors subvec

Clojure vectors subvec

In this guide, we will discuss Clojure Vectors subvec. Returns a sub vector from a starting and ending index.

Syntax

Following is the syntax.

(subvec vec start end)

Parameters − ‘vec’ is the vector set of elements. ‘start’ is the starting index. ‘end’ is the ending index.

Return Value − Returns the new vector from the starting to the ending index.

Example

Following is an example of subvec in Clojure.

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (subvec (vector 1 2 3 4 5 6 7) 2 5)))
(example)

Output

The above code produces the following output.

[3 4 5]

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply