unofficial mirror of bug-gnu-emacs@gnu.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

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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).