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]
clojure_vectors.htm
Advertisements