mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Add new function `seq-remove-at-position'
* doc/lispref/sequences.texi (Sequence Functions): Document it. * lisp/emacs-lisp/seq.el (seq-remove-at-position): New function. * lisp/emacs-lisp/shortdoc.el (sequence): Mention it. * test/lisp/emacs-lisp/seq-tests.el (test-seq-remove-at-position): Test it.
This commit is contained in:
parent
77b761dafa
commit
2db8b0e12f
5 changed files with 48 additions and 0 deletions
|
|
@ -346,6 +346,20 @@ list."
|
|||
(seq-filter (lambda (elt) (not (funcall pred elt)))
|
||||
sequence))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defgeneric seq-remove-at-position (sequence n)
|
||||
"Return a copy of SEQUENCE where the element at N got removed.
|
||||
|
||||
N is the (zero-based) index of the element that should not be in
|
||||
the result.
|
||||
|
||||
The result is a sequence of the same type as SEQUENCE."
|
||||
(seq-concatenate
|
||||
(let ((type (type-of sequence)))
|
||||
(if (eq type 'cons) 'list type))
|
||||
(seq-subseq sequence 0 n)
|
||||
(seq-subseq sequence (1+ n))))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defgeneric seq-reduce (function sequence initial-value)
|
||||
"Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue