pop

functionsince v0.0-927 clojure.core/popEdit
(pop coll)

Details:

For a list, returns a new list without the first item.

For a vector, returns a new vector without the last item.


Examples:

With vectors:

(pop [1 2 3])
;;=> [1 2]

(pop [1 2])
;;=> [1]

(pop [1])
;;=> []

(pop [])
;; Error: Can't pop empty vector

With lists:

(pop '(1 2 3))
;;=> (2 3)

(pop '(1 2))
;;=> (2)

(pop '(1))
;;=> ()

(pop '())
;; Error: Can't pop empty list

See Also:


Source docstring:
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.
Note - not the same as next/butlast.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn pop
  [coll]
  (when-not (nil? coll)
    (-pop coll)))