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:
Damien Cassou 2022-09-03 18:47:04 +02:00 committed by Lars Ingebrigtsen
parent 77b761dafa
commit 2db8b0e12f
5 changed files with 48 additions and 0 deletions

View file

@ -137,6 +137,14 @@ Evaluate BODY for each created sequence.
(with-test-sequences (seq '())
(should (equal (seq-remove #'test-sequences-evenp seq) '()))))
(ert-deftest test-seq-remove-at-position ()
(with-test-sequences (seq '(1 2 3 4))
(should (same-contents-p (seq-remove-at-position seq 2) '(1 2 4)))
(should (same-contents-p (seq-remove-at-position seq 0) '(2 3 4)))
(should (same-contents-p (seq-remove-at-position seq 3) '(1 2 3)))
(should (eq (type-of (seq-remove-at-position seq 2))
(type-of seq)))))
(ert-deftest test-seq-count ()
(with-test-sequences (seq '(6 7 8 9 10))
(should (equal (seq-count #'test-sequences-evenp seq) 3))