function | since v0.0-927 | clojure.core/butlast | Edit |
(butlast s)
Returns a sequence of all but the last item in s
.
butlast
runs in linear time.
(butlast [1 2 3])
;;=> (1 2)
(butlast [1 2])
;;=> (1)
(butlast [1])
;;=> nil
(butlast [])
;;=> nil
Return a seq of all but the last item in coll, in linear time
(defn butlast
[s]
(loop [ret [] s s]
(if (next s)
(recur (conj ret (first s)) (next s))
(seq ret))))