diff options
| author | Nicolas Petton | 2015-02-09 13:14:52 +0100 |
|---|---|---|
| committer | Nicolas Petton | 2015-02-11 14:45:51 +0100 |
| commit | c49e769d8f141b0307db19ed2a5fa80e0696b1dc (patch) | |
| tree | aa4505ccc15006aefe0649c4017e7f133ac57164 /lisp | |
| parent | 061c7e2b5a5a5854b2b85f2ace5b1d9222dd7f11 (diff) | |
| download | emacs-c49e769d8f141b0307db19ed2a5fa80e0696b1dc.tar.gz emacs-c49e769d8f141b0307db19ed2a5fa80e0696b1dc.zip | |
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
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 23 |
2 files changed, 16 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a6e5f59503e..ece253b1336 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2015-02-09 Nicolas Petton <nicolas@petton.fr> | ||
| 2 | |||
| 3 | * emacs-lisp/seq.el (seq-group-by): Improves seq-group-by to | ||
| 4 | return sequence elements in correct order. | ||
| 5 | |||
| 1 | 2015-02-11 Martin Rudalics <rudalics@gmx.at> | 6 | 2015-02-11 Martin Rudalics <rudalics@gmx.at> |
| 2 | 7 | ||
| 3 | * frame.el (toggle-frame-maximized, toggle-frame-fullscreen): | 8 | * frame.el (toggle-frame-maximized, toggle-frame-fullscreen): |
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 025d94e10b9..5fbec185b76 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Nicolas Petton <nicolas@petton.fr> | 5 | ;; Author: Nicolas Petton <nicolas@petton.fr> |
| 6 | ;; Keywords: sequences | 6 | ;; Keywords: sequences |
| 7 | ;; Version: 1.1 | 7 | ;; Version: 1.1.1 |
| 8 | 8 | ||
| 9 | ;; Maintainer: emacs-devel@gnu.org | 9 | ;; Maintainer: emacs-devel@gnu.org |
| 10 | 10 | ||
| @@ -245,17 +245,16 @@ negative integer or 0, nil is returned." | |||
| 245 | "Apply FUNCTION to each element of SEQ. | 245 | "Apply FUNCTION to each element of SEQ. |
| 246 | Separate the elements of SEQ into an alist using the results as | 246 | Separate the elements of SEQ into an alist using the results as |
| 247 | keys. Keys are compared using `equal'." | 247 | keys. Keys are compared using `equal'." |
| 248 | (nreverse | 248 | (seq-reduce |
| 249 | (seq-reduce | 249 | (lambda (acc elt) |
| 250 | (lambda (acc elt) | 250 | (let* ((key (funcall function elt)) |
| 251 | (let* ((key (funcall function elt)) | 251 | (cell (assoc key acc))) |
| 252 | (cell (assoc key acc))) | 252 | (if cell |
| 253 | (if cell | 253 | (setcdr cell (push elt (cdr cell))) |
| 254 | (setcdr cell (push elt (cdr cell))) | 254 | (push (list key elt) acc)) |
| 255 | (push (list key elt) acc)) | 255 | acc)) |
| 256 | acc)) | 256 | (seq-reverse seq) |
| 257 | seq | 257 | nil)) |
| 258 | nil))) | ||
| 259 | 258 | ||
| 260 | (defun seq--drop-list (list n) | 259 | (defun seq--drop-list (list n) |
| 261 | "Return a list from LIST without its first N elements. | 260 | "Return a list from LIST without its first N elements. |