pop

added
1.0

ns
clojure.core

type
function

(pop coll)

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. If
the collection is empty, throws an exception.  Note - not the same
as next/butlast.

                user=> (peek [1 2 3])
3
user=> (pop [1 2 3])
[1 2]
user=> (peek '(1 2 3))
1
user=> (pop '(1 2 3))
(2 3)
            
                user=> (peek ())
nil
user=> (pop ())
IllegalStateException Can't pop empty list

user=> (peek [])
nil
user=> (pop [])
IllegalStateException Can't pop empty vector