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

Full log


View this message in rfc822 format

From: Marco Wahl <marcowahlsoft <at> gmail.com>
To: 52383 <at> debbugs.gnu.org
Subject: bug#52383: 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




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.