clojure.core/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. If the collection is empty, throws an exception. Note - not the same as next/butlast.
Examples¶
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¶
- clojure.core/peek (3)
- clojure.core/rest (6)
- clojure.core/conj (9)
- clojure.core/butlast (4)
- clojure.core/pop!
Content from the matching ClojureDocs page, with authors credited on each contribution.