pop
Retrieves a new array without the last element from an input array
(pop arr)
Returns
The function returns a new array that contains all elements of the input array except the last one.
Parameters
arr (array) - the input array from which the last element is to be excluded.
Examples
(pop [1, 2, 3])
;;=> [1, 2]
(def arr1 [1, 2, 3])
(pop arr1)
;;=> [1, 2]
arr1 ;; arr1 remains the same
;;=> [1, 2, 3]
(pop! arr1)
;;=> 3
arr1
;;=> [1, 2]
Was this helpful?