From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] New package: find-dups Date: Thu, 12 Oct 2017 10:37:02 +0200 Message-ID: <87y3ogsqxd.fsf@hochschule-trier.de> References: <87fuapemew.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1507797477 32611 195.159.176.226 (12 Oct 2017 08:37:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 12 Oct 2017 08:37:57 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: Emacs Development To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 12 10:37:52 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2Yzw-0006zA-He for ged-emacs-devel@m.gmane.org; Thu, 12 Oct 2017 10:37:44 +0200 Original-Received: from localhost ([::1]:44313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2Z02-0001AX-GF for ged-emacs-devel@m.gmane.org; Thu, 12 Oct 2017 04:37:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2YzQ-0001AR-Rc for emacs-devel@gnu.org; Thu, 12 Oct 2017 04:37:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2YzN-00088I-LR for emacs-devel@gnu.org; Thu, 12 Oct 2017 04:37:12 -0400 Original-Received: from gateway-a.fh-trier.de ([143.93.54.181]:45018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e2YzN-00085l-Ao for emacs-devel@gnu.org; Thu, 12 Oct 2017 04:37:09 -0400 X-Virus-Scanned: by Amavisd-new + Sophos + ClamAV [Rechenzentrum Hochschule Trier (RZ/HT)] Original-Received: from localhost (ip5886048c.dynamic.kabel-deutschland.de [88.134.4.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id 008F017A688C; Thu, 12 Oct 2017 10:37:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1507797425; bh=xl9o9WjkZfM6O/Oc5vNj6U4vQPw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; b=gPkki3ZX7lW9lXVzOeJygzh9EcIfY19B75ucdAzUKM9WHDk9pI+7Y5PWquzf+bs2B oYnvBK2TbBFuU0R5C6ju3nCOxIabUApZ3P9iw8wUbp/csZvbzyM4hpI1TBa1ncY60L dXH856P/UVAZ+zrhaJ0W7jmQFNTla0SQLS5CDZFg= In-Reply-To: <87fuapemew.fsf@web.de> (Michael Heerdegen's message of "Wed, 11 Oct 2017 17:25:59 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 143.93.54.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:219405 Archived-At: What you seem to be doing is something like this (minus equal vs eq). #+BEGIN_SRC emacs-lisp (defun partition-by (s &rest fns) "Partition sequence S by some function F. Partition S using a equivalence relation R constructed by F, such that for all x,y =E2=88=88 S (x, y) =E2=88=88 R =E2=87=94 f(x) =3D f(y) . If GS is non-nil, it should be a list of functions acting as necessary conditions, such that for all x,y =E2=88=88 S and g=E2=82=81=CC=A3,..,g= =E2=82=99 =E2=88=88 GS: g=E2=82=81(x) =3D g=E2=82=81(y) =E2=87=90 ... =E2=87=90 g=E2=82=99(= x) =3D g=E2=82=99(y) =E2=87=90 f(x) =3D f(y) The idea is that the functions in GS may be computed more efficiently than F and thus allowing for an overall faster computation of the partition in some cases. Returns the partition of S as a list of lists. \(FN S &rest G1 ... GN F\)" (cond ((=3D (length s) 0) nil) ((or (null fns) (< (length s) 2)) (list s)) (t (seq-mapcat (lambda (elt) (apply #'partition-by (cdr elt) (cdr fns))) (seq-group-by (car fns) s))))) (partition-by (seq-filter #'file-regular-p (directory-files "/tmp" t)) (lambda (file) (nth 7 (file-attributes file))) (lambda (file) (with-temp-buffer (insert-file-contents-literally file) (md5 (current-buffer))))) #+END_SRC Andreas