From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#34852: 26.1; seq-intersection ignores nil as element Date: Thu, 14 Mar 2019 16:17:28 +0000 Message-ID: <87va0lctwn.fsf@tcd.ie> References: <87zhpxabn3.fsf@tcd.ie> <87va0lmwlg.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="215780"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Nicolas Petton , "Miguel V. S. Frasson" , 34852@debbugs.gnu.org, Stefan Monnier To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 14 17:23:01 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4T8G-000tzN-N2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2019 17:23:00 +0100 Original-Received: from localhost ([127.0.0.1]:41004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4T8F-000510-Nu for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Mar 2019 12:22:59 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4T3b-0001iZ-HJ for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2019 12:18:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4T3W-0004Gf-8O for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2019 12:18:09 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58615) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4T3S-0004ED-Kw for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2019 12:18:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h4T3S-0002uh-GK for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2019 12:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Mar 2019 16:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34852 X-GNU-PR-Package: emacs Original-Received: via spool by 34852-submit@debbugs.gnu.org id=B34852.155258025711159 (code B ref 34852); Thu, 14 Mar 2019 16:18:02 +0000 Original-Received: (at 34852) by debbugs.gnu.org; 14 Mar 2019 16:17:37 +0000 Original-Received: from localhost ([127.0.0.1]:43925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h4T33-0002tv-4N for submit@debbugs.gnu.org; Thu, 14 Mar 2019 12:17:37 -0400 Original-Received: from mail-ed1-f43.google.com ([209.85.208.43]:34347) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h4T31-0002tj-M3 for 34852@debbugs.gnu.org; Thu, 14 Mar 2019 12:17:36 -0400 Original-Received: by mail-ed1-f43.google.com with SMTP id a16so5149865edn.1 for <34852@debbugs.gnu.org>; Thu, 14 Mar 2019 09:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=PQBHAfVMSKbXup+ds3KF+4q598KqHgCL0cLu2zp/AD8=; b=ZBFlAOVpLAfMFdlupYnZM4cNhcqKrQ2exOXUvufCB9y7WdFS9MM1J6sdh+exLLxDCw 68EAXFWk965U2nnawfP5iwzLhnShkn2wMmOEbGxViRTGfY7PlZZfiNL/e++TKUz4APkR C5GP3jUqLOVgsQ7Pn/cKYZjq4zDzOfPkLw4ObGwKoO/Xk/GslFwIZOAiseK6DXvXB3Jx lFRNF0sYI48/mBWKNWnJreAleRqXGxcJAK8o7tk/6DGi7b9YjE+PEtb8SzcvviDvZ0ma RypK2KCIz6B6Rp3gl5XSKrxDDsOfZdmF6ErUYPIr5x3msNL18N1s4J8oJXKPMGBSBcs+ SSGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=PQBHAfVMSKbXup+ds3KF+4q598KqHgCL0cLu2zp/AD8=; b=ny71y6FcZ4gxQYHRBsRrxKAPfw2DTh+YENAFFNOcEMgWxvaFlLR+K7r4lyZeVBLc1J 0neswJoBVAYaRnYbo4fPneuDk+0hXeDPVWSAFXJutdgf6ks6eSGN+UeGDuakMrUPsMKO wCQR3s2HK7AjJlMAo7U2VKIzIflu7yorS0UE4vHdwy+UGOV1szw+h1fUcC3DKe+x+71x Qyk4mNpMOJJ+n4JBjyhnK7pBuSRo6tCgIWjvZlROBW51JwSMHWbdN+lhlIsnlXtTKVot HsTqTtzc1oJm4XjubMy7z1bg8YUZKqA5AkxMMLgSQl8ps/QBLRCiNOAe5mg6XPgWcPcz nMeg== X-Gm-Message-State: APjAAAVa5xhllhnS28lNvdquGbDEAp7UkZYJ/TTkowowAey2wihKeE/L ovxvIFOyNFfShNLrElvf3GasRA== X-Google-Smtp-Source: APXvYqzKdpPQAhRoDzRkO4G94Q9rVbcTGrALtGGtJ+ve3P2JeJxm95ZBGP0634RVX29ieVF76HCZCw== X-Received: by 2002:a17:906:7045:: with SMTP id r5mr10196391ejj.147.1552580249886; Thu, 14 Mar 2019 09:17:29 -0700 (PDT) Original-Received: from localhost ([134.226.214.246]) by smtp.gmail.com with ESMTPSA id g32sm333829ede.78.2019.03.14.09.17.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 14 Mar 2019 09:17:29 -0700 (PDT) In-Reply-To: <87va0lmwlg.fsf@web.de> (Michael Heerdegen's message of "Thu, 14 Mar 2019 14:09:15 +0100") 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: 209.51.188.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:156338 Archived-At: Michael Heerdegen writes: > "Basil L. Contovounesios" writes: > >> One solution is to leave seq-contains as it is, and switch to using >> seq-position (or some new predicate) as a predicate instead. Another is >> to make seq-contains return a boolean instead of the needle found, which >> would be a backward-incompatible change similar to that for >> map-contains-key. I attach a patch for each of these respective >> solutions; WDYT? > > We also have `seq-some' which can be used as a contain predicate, > e.g. to fix this bug: > > From c53a80c29e696ab64d4279ca6f495c8e0e1b16b4 Mon Sep 17 00:00:00 2001 > From: Michael Heerdegen > Date: Thu, 14 Mar 2019 13:55:41 +0100 > Subject: [PATCH] Fix seq-intersection with nil > > --- > lisp/emacs-lisp/seq.el | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el > index 4a811d7895..5718343a8f 100644 > --- a/lisp/emacs-lisp/seq.el > +++ b/lisp/emacs-lisp/seq.el > @@ -409,12 +409,13 @@ seq-sort-by > (cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn) > "Return a list of the elements that appear in both SEQUENCE1 and SEQUENCE2. > Equality is defined by TESTFN if non-nil or by `equal' if nil." > - (seq-reduce (lambda (acc elt) > - (if (seq-contains sequence2 elt testfn) > - (cons elt acc) > - acc)) > - (seq-reverse sequence1) > - '())) > + (let ((testfn (or testfn #'equal))) > + (seq-reduce (lambda (acc elt) > + (if (seq-some (apply-partially testfn elt) sequence2) > + (cons elt acc) > + acc)) > + (seq-reverse sequence1) > + '()))) > > (cl-defgeneric seq-difference (sequence1 sequence2 &optional testfn) > "Return a list of the elements that appear in SEQUENCE1 but not in SEQUENCE2. > -- > 2.20.1 > > > (probably needed in more places as you did in one of your patches) > > So I think we don't necessarily need something new or a backward > incompatible change. My first patch makes an analogous backward-compatible change using the more efficient seq-position in place of seq-some. Thanks, -- Basil