all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
@ 2021-12-09  0:55 Marco Wahl
  2021-12-09  9:01 ` Juri Linkov
  2021-12-10  1:45 ` Michael Heerdegen
  0 siblings, 2 replies; 10+ messages in thread
From: Marco Wahl @ 2021-12-09  0:55 UTC (permalink / raw)
  To: 52383


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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-09  0:55 bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el Marco Wahl
@ 2021-12-09  9:01 ` Juri Linkov
  2021-12-09 20:21   ` Marco Wahl
  2021-12-10  1:45 ` Michael Heerdegen
  1 sibling, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2021-12-09  9:01 UTC (permalink / raw)
  To: Marco Wahl; +Cc: 52383

> 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'.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-09  9:01 ` Juri Linkov
@ 2021-12-09 20:21   ` Marco Wahl
  2021-12-09 20:29     ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: Marco Wahl @ 2021-12-09 20:21 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52383

Juri Linkov <juri@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!





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-09 20:21   ` Marco Wahl
@ 2021-12-09 20:29     ` Juri Linkov
  2021-12-09 21:23       ` Marco Wahl
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2021-12-09 20:29 UTC (permalink / raw)
  To: Marco Wahl; +Cc: 52383

>>> 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'.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-09 20:29     ` Juri Linkov
@ 2021-12-09 21:23       ` Marco Wahl
  0 siblings, 0 replies; 10+ messages in thread
From: Marco Wahl @ 2021-12-09 21:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52383

Juri Linkov <juri@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.






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-09  0:55 bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el Marco Wahl
  2021-12-09  9:01 ` Juri Linkov
@ 2021-12-10  1:45 ` Michael Heerdegen
  2021-12-10 12:01   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2021-12-10  1:45 UTC (permalink / raw)
  To: Marco Wahl; +Cc: 52383

Marco Wahl <marcowahlsoft@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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-10  1:45 ` Michael Heerdegen
@ 2021-12-10 12:01   ` Lars Ingebrigtsen
  2021-12-11 18:40     ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-10 12:01 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 52383, Marco Wahl

Michael Heerdegen <michael_heerdegen@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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-10 12:01   ` Lars Ingebrigtsen
@ 2021-12-11 18:40     ` Juri Linkov
  2021-12-12  1:19       ` Michael Heerdegen
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2021-12-11 18:40 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Michael Heerdegen, 52383, Marco Wahl

>> 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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-11 18:40     ` Juri Linkov
@ 2021-12-12  1:19       ` Michael Heerdegen
  2021-12-12  4:57         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2021-12-12  1:19 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 52383, Lars Ingebrigtsen, Marco Wahl

Juri Linkov <juri@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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el
  2021-12-12  1:19       ` Michael Heerdegen
@ 2021-12-12  4:57         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-12  4:57 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 52383, Marco Wahl, Juri Linkov

Michael Heerdegen <michael_heerdegen@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





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-12-12  4:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-09  0:55 bug#52383: 29.0.50; [suggestion] Add seq-set-subset-p to seq.el Marco Wahl
2021-12-09  9:01 ` Juri Linkov
2021-12-09 20:21   ` Marco Wahl
2021-12-09 20:29     ` Juri Linkov
2021-12-09 21:23       ` Marco Wahl
2021-12-10  1:45 ` Michael Heerdegen
2021-12-10 12:01   ` Lars Ingebrigtsen
2021-12-11 18:40     ` Juri Linkov
2021-12-12  1:19       ` Michael Heerdegen
2021-12-12  4:57         ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.