Skip to content

clojure.core/pop

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 4 Runnable: 2
([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.

Examples

by pkolloch on
by HomoEfficio on . May have evaluation errors.
by reborg on . May have evaluation errors.
by ibercode on

Note by tomby42

Small reminder:


Do not work for arbitrary seq but just for persistent types implementing clojure.lang.IPersistentStack (like clojure.lang.Persistent*).


Example:

user> (pop (cons 1 '()))
; Evaluation aborted.

do not work because type is clojure.lang.Cons but

user> (pop (conj '() 1))
()

works because type is clojure.lang.PersistentList.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.