butlast

functionsince v0.0-927 clojure.core/butlastEdit
(butlast s)

Details:

Returns a sequence of all but the last item in s.

butlast runs in linear time.


Examples:

(butlast [1 2 3])
;;=> (1 2)

(butlast [1 2])
;;=> (1)

(butlast [1])
;;=> nil

(butlast [])
;;=> nil

See Also:


Source docstring:
Return a seq of all but the last item in coll, in linear time
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn butlast
  [s]
  (loop [ret [] s s]
    (if (next s)
      (recur (conj ret (first s)) (next s))
      (seq ret))))