From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.devel Subject: Re: Would seq-range and seq-mapcat be useful? Date: Fri, 30 Jan 2015 16:59:44 +0100 Message-ID: <87wq448djj.fsf@yahoo.fr> References: <878uglwmra.fsf@petton.fr> <874mr9w8at.fsf@petton.fr> <87lhkkefhn.fsf@petton.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422633583 2832 80.91.229.3 (30 Jan 2015 15:59:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Jan 2015 15:59:43 +0000 (UTC) Cc: Nicolas Petton , Stefan Monnier , emacs-devel To: Oleh Krehel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 30 16:59:42 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YHDys-0002hx-9h for ged-emacs-devel@m.gmane.org; Fri, 30 Jan 2015 16:59:38 +0100 Original-Received: from localhost ([::1]:37453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHDyr-0006B7-RQ for ged-emacs-devel@m.gmane.org; Fri, 30 Jan 2015 10:59:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHDyn-0006AP-PI for emacs-devel@gnu.org; Fri, 30 Jan 2015 10:59:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHDyi-0001cw-Pg for emacs-devel@gnu.org; Fri, 30 Jan 2015 10:59:33 -0500 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:3842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHDyi-0001aG-Jh for emacs-devel@gnu.org; Fri, 30 Jan 2015 10:59:28 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmAFAMGpy1SkD4Xx/2dsb2JhbABahDGyIwEBAQEBAQaYMAKBYAEBAQEBfYQNAQV5EAgDDhMlDwEEDTwTiBcBAxHDJI1bAUoNhVIBAQgCAR+GBIIqhSCCKgeEKQWWWIFGhimGLIV8IoIBHYFRPTGCQgEBAQ Original-Received: from mathsrv4.ulb.ac.be (HELO localhost) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 30 Jan 2015 16:59:26 +0100 In-Reply-To: (Oleh Krehel's message of "Fri, 30 Jan 2015 16:38:24 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 164.15.128.112 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182066 Archived-At: Oleh Krehel 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