Function: nnselect-categorize

nnselect-categorize is an autoloaded and byte-compiled function defined in nnselect.el.gz.

Signature

(nnselect-categorize SEQUENCE KEYFUNC &optional VALUEFUNC)

Documentation

Sorts a sequence into categories.

Returns a list of the form
((key1 (element11 element12)) (key2 (element21 element22)).
The category key for a member of the sequence is obtained as (keyfunc member) and the corresponding element is just member (or (valuefunc member) if valuefunc is non-nil).

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnselect.el.gz
(define-inline nnselect-categorize (sequence keyfunc &optional valuefunc)
  "Sorts a sequence into categories.
Returns a list of the form
`((key1 (element11 element12)) (key2 (element21 element22))'.
The category key for a member of the sequence is obtained
as `(keyfunc member)' and the corresponding element is just
`member' (or `(valuefunc member)' if `valuefunc' is non-nil)."
  (inline-letevals (sequence keyfunc valuefunc)
    (inline-quote  (let ((valuefunc (or ,valuefunc 'identity))
			 result)
		     (unless (null ,sequence)
		      (mapc
		       (lambda (member)
			 (let* ((key (funcall ,keyfunc member))
				(value  (funcall valuefunc member))
				(kr (assoc key result)))
			   (if kr
			       (push value (cdr kr))
			     (push (list key value) result))))
		       (reverse ,sequence))
		      result)))))