Function: butlast

butlast is a byte-compiled function defined in subr.el.gz.

Signature

(butlast LIST &optional N)

Documentation

Return a copy of LIST with the last N elements removed.

If N is omitted or nil, the last element is removed from the copy.

Other relevant functions are documented in the list group.

Probably introduced at or before Emacs version 21.1.

Shortdoc

;; list
(butlast '(one two three))
    => (one two)

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun butlast (list &optional n)
  "Return a copy of LIST with the last N elements removed.
If N is omitted or nil, the last element is removed from the
copy."
  (declare (side-effect-free t))
  (if (and n (<= n 0)) list
    (nbutlast (copy-sequence list) n)))