New convenience functions in seq.el
Functions to access the first or all but the first elements of sequences have been repeatedly asked for (the last occurrence being https://github.com/NicolasPetton/seq.el/issues/9). * lisp/emacs-lisp/seq.el (seq-first, seq-rest): New functions. * test/lisp/emacs-lisp/seq-tests.el (test-seq-first, test-seq-rest): New tests for seq-first and seq-rest.
This commit is contained in:
parent
73b2f7ac69
commit
5a9eba603d
2 changed files with 21 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
;; Author: Nicolas Petton <nicolas@petton.fr>
|
||||
;; Keywords: sequences
|
||||
;; Version: 2.20
|
||||
;; Version: 2.21
|
||||
;; Package: seq
|
||||
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
@ -110,6 +110,14 @@ name to be bound to the rest of SEQUENCE."
|
|||
"Return the number of elements of SEQUENCE."
|
||||
(length sequence))
|
||||
|
||||
(defun seq-first (sequence)
|
||||
"Return the first element of SEQUENCE."
|
||||
(seq-elt sequence 0))
|
||||
|
||||
(defun seq-rest (sequence)
|
||||
"Return a sequence of the elements of SEQUENCE except the first one."
|
||||
(seq-drop sequence 1))
|
||||
|
||||
(cl-defgeneric seq-do (function sequence)
|
||||
"Apply FUNCTION to each element of SEQUENCE, presumably for side effects.
|
||||
Return SEQUENCE."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue