Clojure – Vectors pop

Clojure vectors pop

In this guide, we will discuss Clojure Vectors pop. For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item.

Syntax

Following is the syntax.

(pop vec)

Parameters − ‘vec’ is the vector set of elements.

Return Value − Returns the new vector without the last item.

Example

Following is an example of pop in Clojure.

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (pop (vector 3 2 1))))
(example)

Output

The above code produces the following output.

[3 2]

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply