|
From: | Nicolas Richard |
Subject: | Re: Would seq-range and seq-mapcat be useful? |
Date: | Fri, 30 Jan 2015 16:59:44 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Oleh Krehel <address@hidden> writes: > Is this already somewhere? IDK, but I often wrote this kind of snippet for that purpose : (defun yf/seq-group-by (fn lst) (let ((hash (make-hash-table :test 'equal))) (dolist (elm lst) (push elm (gethash (funcall fn elm) hash))) hash)) (yf/seq-group-by #'car '(("a" 1) ("b" 2) ("b" 5) ("c" 1))) => #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("a" (("a" 1)) "b" (("b" 5) ("b" 2)) "c" (("c" 1)))) -- Nicolas Richard
[Prev in Thread] | Current Thread | [Next in Thread] |