GNU bug report logs - #52383
29.0.50; [suggestion] Add seq-set-subset-p to seq.el

Previous Next

Package: emacs;

Reported by: Marco Wahl <marcowahlsoft <at> gmail.com>

Date: Thu, 9 Dec 2021 00:56:02 UTC

Severity: wishlist

Found in version 29.0.50

To reply to this bug, email your comments to 52383 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Thu, 09 Dec 2021 00:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marco Wahl <marcowahlsoft <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 09 Dec 2021 00:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Marco Wahl <marcowahlsoft <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Thu, 09 Dec 2021 01:55:13 +0100
I suggest adding seq-set-subset-p to seq.el to realize the typical math
subset predicate.

(cl-defgeneric seq-set-subset-p (sequence1 sequence2 &optional testfn)
  "Return non-nil if the elements of SEQUENCE1 are contained in SEQUENCE2.
This does not depend on the order of the elements.
Equality is defined by TESTFN if non-nil or by `equal' if nil."
  (seq-every-p (lambda (item1) (seq-contains-p sequence2 item1 testfn)) sequence1))

;; test:
(should (seq-set-subset-p "ab" "abc"))
(should (seq-set-subset-p "ba" "abc"))
(should-not (seq-set-subset-p "dabc" "abc"))


That functionality is missing AFAICS.

The function could be placed naturally between the functions `seq-contains-p'
and `seq-set-equal-p'.

BTW function `seq-set-equal-p' could be rewritten using
`seq-set-subset-p'.


Thanks for reading,
-- 
Marco




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Thu, 09 Dec 2021 09:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Marco Wahl <marcowahlsoft <at> gmail.com>
Cc: 52383 <at> debbugs.gnu.org
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Thu, 09 Dec 2021 11:01:54 +0200
> BTW function `seq-set-equal-p' could be rewritten using
> `seq-set-subset-p'.

Isn't the word "set" redundant in the name?
In `seq-set-equal-p' the word "set" is needed
to say "is set equal".  But in `seq-set-subset-p'
the word "set" doesn't add much meaning, so better
would be to name your new function just `seq-subset-p'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Thu, 09 Dec 2021 20:22:02 GMT) Full text and rfc822 format available.

Message #11 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Marco Wahl <marcowahlsoft <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52383 <at> debbugs.gnu.org
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Thu, 09 Dec 2021 21:21:14 +0100
Juri Linkov <juri <at> linkov.net> writes:

>> BTW function `seq-set-equal-p' could be rewritten using
>> `seq-set-subset-p'.
>
> Isn't the word "set" redundant in the name?
> In `seq-set-equal-p' the word "set" is needed
> to say "is set equal".  But in `seq-set-subset-p'
> the word "set" doesn't add much meaning, so better
> would be to name your new function just `seq-subset-p'.

Agreed.

The motivation for the suggested name `seq-set-subset-p' was to stay
close to the name `seq-set-equal-p'.  A user could interpret the prefix
"seq-set" as hint that the function implements a set operation.


Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Thu, 09 Dec 2021 20:31:01 GMT) Full text and rfc822 format available.

Message #14 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Marco Wahl <marcowahlsoft <at> gmail.com>
Cc: 52383 <at> debbugs.gnu.org
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Thu, 09 Dec 2021 22:29:53 +0200
>>> BTW function `seq-set-equal-p' could be rewritten using
>>> `seq-set-subset-p'.
>>
>> Isn't the word "set" redundant in the name?
>> In `seq-set-equal-p' the word "set" is needed
>> to say "is set equal".  But in `seq-set-subset-p'
>> the word "set" doesn't add much meaning, so better
>> would be to name your new function just `seq-subset-p'.
>
> Agreed.
>
> The motivation for the suggested name `seq-set-subset-p' was to stay
> close to the name `seq-set-equal-p'.  A user could interpret the prefix
> "seq-set" as hint that the function implements a set operation.

I guess the only reason why `seq-set-equal-p' has the prefix `seq-set-'
is because it would be too ambiguous without the prefix: `seq-equal-p'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Thu, 09 Dec 2021 21:24:01 GMT) Full text and rfc822 format available.

Message #17 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Marco Wahl <marcowahlsoft <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52383 <at> debbugs.gnu.org
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Thu, 09 Dec 2021 22:23:07 +0100
Juri Linkov <juri <at> linkov.net> writes:

>> The motivation for the suggested name `seq-set-subset-p' was to stay
>> close to the name `seq-set-equal-p'.  A user could interpret the prefix
>> "seq-set" as hint that the function implements a set operation.
>
> I guess the only reason why `seq-set-equal-p' has the prefix `seq-set-'
> is because it would be too ambiguous without the prefix: `seq-equal-p'.

I guess so too.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Fri, 10 Dec 2021 01:46:01 GMT) Full text and rfc822 format available.

Message #20 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Marco Wahl <marcowahlsoft <at> gmail.com>
Cc: 52383 <at> debbugs.gnu.org
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Fri, 10 Dec 2021 02:45:23 +0100
Marco Wahl <marcowahlsoft <at> gmail.com> writes:

> I suggest adding seq-set-subset-p to seq.el to realize the typical
> math subset predicate.

If I recall correctly, Stefan wanted a set.el library.  I only want to
mention that, because... well, it's related (and we already found that
"subsequence" testing is not what this implements).

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Fri, 10 Dec 2021 12:02:01 GMT) Full text and rfc822 format available.

Message #23 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 52383 <at> debbugs.gnu.org, Marco Wahl <marcowahlsoft <at> gmail.com>
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Fri, 10 Dec 2021 13:01:11 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> If I recall correctly, Stefan wanted a set.el library.  I only want to
> mention that, because... well, it's related (and we already found that
> "subsequence" testing is not what this implements).

Yes, I'd rather have a set.el than adding some set commands to seq.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 11 Dec 2021 01:31:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Sat, 11 Dec 2021 18:53:02 GMT) Full text and rfc822 format available.

Message #28 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 52383 <at> debbugs.gnu.org,
 Marco Wahl <marcowahlsoft <at> gmail.com>
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Sat, 11 Dec 2021 20:40:38 +0200
>> If I recall correctly, Stefan wanted a set.el library.  I only want to
>> mention that, because... well, it's related (and we already found that
>> "subsequence" testing is not what this implements).
>
> Yes, I'd rather have a set.el than adding some set commands to seq.

There are already some commands in seq that look like set commands:
seq-union, seq-intersection, seq-difference.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Sun, 12 Dec 2021 01:20:02 GMT) Full text and rfc822 format available.

Message #31 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 52383 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Marco Wahl <marcowahlsoft <at> gmail.com>
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Sun, 12 Dec 2021 02:19:46 +0100
Juri Linkov <juri <at> linkov.net> writes:

> There are already some commands in seq that look like set commands:
> seq-union, seq-intersection, seq-difference.

Yes, but that's unfortunate, and we need to stop at some point.  These
functions also don't really fit in seq.el.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52383; Package emacs. (Sun, 12 Dec 2021 04:59:02 GMT) Full text and rfc822 format available.

Message #34 received at 52383 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 52383 <at> debbugs.gnu.org, Marco Wahl <marcowahlsoft <at> gmail.com>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
Date: Sun, 12 Dec 2021 05:57:45 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

>> There are already some commands in seq that look like set commands:
>> seq-union, seq-intersection, seq-difference.
>
> Yes, but that's unfortunate, and we need to stop at some point.  These
> functions also don't really fit in seq.el.

And they're too slow to be used for even smallish sets.  So we should
grow a set.el library that is more efficient CPU-wise.  (The set
functions in seq.el are efficient RAM-wise, though.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 3 years and 248 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.