Function: seq-group-by
seq-group-by is an autoloaded and byte-compiled function defined in
seq-25.el.
Signature
(seq-group-by FUNCTION SEQUENCE)
Documentation
Apply FUNCTION to each element of SEQUENCE.
Separate the elements of SEQUENCE into an alist using the results as
keys. Keys are compared using equal.
Other relevant functions are documented in the sequence group.
Shortdoc
;; sequence
(seq-group-by #'cl-plusp '(-1 2 3 -4 -5 6))
=> ((nil -1 -4 -5) (t 2 3 6))
Implementations
#'sequence in `seq-25.el'.
Undocumented
Source Code
;; Defined in ~/.emacs.d/elpa/seq-2.24/seq-25.el
;;;###autoload
(cl-defgeneric seq-group-by (function sequence)
"Apply FUNCTION to each element of SEQUENCE.
Separate the elements of SEQUENCE into an alist using the results as
keys. Keys are compared using `equal'."
(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 sequence)
nil))