mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Improve seq-group-by to return sequence elements in correct order
* lisp/emacs-lisp/seq.el (seq-group-by): Improves seq-group-by to return sequence elements in correct order * tests/automated/seq-tests.el: Update test for seq-group-by * doc/lispref/sequences.texi (Sequence Functions): Update documentation examples for seq-group-by
This commit is contained in:
parent
061c7e2b5a
commit
c49e769d8f
6 changed files with 32 additions and 17 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
;; Author: Nicolas Petton <nicolas@petton.fr>
|
||||
;; Keywords: sequences
|
||||
;; Version: 1.1
|
||||
;; Version: 1.1.1
|
||||
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
||||
|
|
@ -245,17 +245,16 @@ negative integer or 0, nil is returned."
|
|||
"Apply FUNCTION to each element of SEQ.
|
||||
Separate the elements of SEQ into an alist using the results as
|
||||
keys. Keys are compared using `equal'."
|
||||
(nreverse
|
||||
(seq-reduce
|
||||
(lambda (acc elt)
|
||||
(let* ((key (funcall function elt))
|
||||
(cell (assoc key acc)))
|
||||
(if cell
|
||||
(setcdr cell (push elt (cdr cell)))
|
||||
(push (list key elt) acc))
|
||||
acc))
|
||||
seq
|
||||
nil)))
|
||||
(seq-reduce
|
||||
(lambda (acc elt)
|
||||
(let* ((key (funcall function elt))
|
||||
(cell (assoc key acc)))
|
||||
(if cell
|
||||
(setcdr cell (push elt (cdr cell)))
|
||||
(push (list key elt) acc))
|
||||
acc))
|
||||
(seq-reverse seq)
|
||||
nil))
|
||||
|
||||
(defun seq--drop-list (list n)
|
||||
"Return a list from LIST without its first N elements.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue