mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
(butlast, nbutlast): Moved from cl.el to here.
This commit is contained in:
parent
a816f1c545
commit
1c1c65de36
1 changed files with 14 additions and 0 deletions
14
lisp/subr.el
14
lisp/subr.el
|
|
@ -135,6 +135,20 @@ If N is bigger than the length of X, return X."
|
|||
(setq x (cdr x)))
|
||||
x))
|
||||
|
||||
(defun butlast (x &optional n)
|
||||
"Returns a copy of LIST with the last N elements removed."
|
||||
(if (and n (<= n 0)) x
|
||||
(nbutlast (copy-sequence x) n)))
|
||||
|
||||
(defun nbutlast (x &optional n)
|
||||
"Modifies LIST to remove the last N elements."
|
||||
(let ((m (length x)))
|
||||
(or n (setq n 1))
|
||||
(and (< n m)
|
||||
(progn
|
||||
(if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
|
||||
x))))
|
||||
|
||||
(defun remove (elt seq)
|
||||
"Return a copy of SEQ with all occurences of ELT removed.
|
||||
SEQ must be a list, vector, or string. The comparison is done with `equal'."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue