From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#26540: 25.2; [PATCH] Add cl-set-equal to test for set equality Date: Wed, 19 Apr 2017 23:19:03 +0200 Message-ID: <87lgqwdrjs.fsf@drachen> References: <87bmrve6n9.fsf@cassou.me> <87vaq0hh3f.fsf@petton.fr> <87wpag8yog.fsf@cassou.me> <87tw5k8w4g.fsf@cassou.me> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1492637092 18065 195.159.176.226 (19 Apr 2017 21:24:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Apr 2017 21:24:52 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: John Mastro , Nicolas Petton , 26540@debbugs.gnu.org To: Damien Cassou Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 19 23:24:43 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1d0x5f-0004RH-7K for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Apr 2017 23:24:43 +0200 Original-Received: from localhost ([::1]:50483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0x5h-00085L-HO for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Apr 2017 17:24:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0x1B-0004Ci-6c for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 17:20:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0x18-0007sD-1U for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 17:20:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0x17-0007rz-UZ for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 17:20:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d0x17-000733-Kb for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 17:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Apr 2017 21:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26540 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 26540-submit@debbugs.gnu.org id=B26540.149263676327043 (code B ref 26540); Wed, 19 Apr 2017 21:20:01 +0000 Original-Received: (at 26540) by debbugs.gnu.org; 19 Apr 2017 21:19:23 +0000 Original-Received: from localhost ([127.0.0.1]:57487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0x0V-000727-Iv for submit@debbugs.gnu.org; Wed, 19 Apr 2017 17:19:23 -0400 Original-Received: from mout.web.de ([212.227.15.14]:64089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0x0T-00071r-CK for 26540@debbugs.gnu.org; Wed, 19 Apr 2017 17:19:22 -0400 Original-Received: from drachen.dragon ([94.216.184.104]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LZkTs-1cJxHx1U56-00lTW4; Wed, 19 Apr 2017 23:18:57 +0200 In-Reply-To: <87tw5k8w4g.fsf@cassou.me> (Damien Cassou's message of "Wed, 19 Apr 2017 13:39:11 +0200") X-Provags-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v7GpLXMj9YG1g2l64DMDD+ X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131768 Archived-At: Damien Cassou writes: > Damien Cassou writes: > > it makes sense and I will try this way. Nevertheless, it also means > > giving up on the :key feature. I guess it's ok. OTOH I see no reason not to support it. There is no reason to provide a function in a library specializing on sequences with less features than in some other lib. Just my personal opinion. Of course you can get the effect of :key by adopting the TESTFN, but also note my other comment: > here it is. Any feedback? It might be worth it to try to optimize things a bit for the most usual TESTFNs `eq' and `equal'. For example, try #+begin_src emacs-lisp (let ((s1 (number-sequence 1 10000)) (s2 (number-sequence 1 10000))) (seq-set-equal s1 s2)) #+end_src vs. #+begin_src emacs-lisp (let ((s1 (number-sequence 1 10000)) (s2 (number-sequence 1 10000))) (seq-set-equal-2 s1 s2)) #+end_src with this implementation using hash-tables: #+begin_src emacs-lisp (defun seq-set-equal-2 (sequence1 sequence2) (let ((table1 (make-hash-table :size (length sequence1))) (table2 (make-hash-table :size (length sequence2)))) (seq-doseq (elt sequence1) (puthash elt t table1)) (seq-doseq (elt sequence2) (puthash elt t table2)) (and (seq-every-p (lambda (elt) (gethash elt table2)) sequence1) (seq-every-p (lambda (elt) (gethash elt table1)) sequence2)))) #+end_src I guess other functions in seq.el could be optimized as well, e.g. `seq-difference'. Regards, Michael.