From: Arthur Miller <arthur.miller@live.com>
To: Hans Lonsdale <hanslonsdale@mailfence.com>
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Finding repetitions of 8-tuples
Date: Sun, 01 Jan 2023 16:13:50 +0100 [thread overview]
Message-ID: <AM9PR09MB4977292E2D6088645EBE316C96F69@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <1399831366.706043.1672506045023@ichabod.co-bxl> (Hans Lonsdale's message of "Sat, 31 Dec 2022 18:00:45 +0100 (CET)")
Hans Lonsdale <hanslonsdale@mailfence.com> writes:
> I have 16 collections of 8 numbers
>
> (11 12 11 44 11 12 11 23)
> (12 21 11 44 11 12 11 23)
> and so on
>
> I want to find whether there are repetitions of each 8-tuple.
> The order in which the numbers occur is not important.
Have you looked at "lists as sets" chapter in the manual?
There is a 'cl-subsetp' you could start with:
cl-subsetp is an autoloaded native-compiled Lisp function in ‘cl-seq.el’.
(cl-subsetp LIST1 LIST2 [KEYWORD VALUE]...)
Return true if LIST1 is a subset of LIST2.
I.e., if every element of LIST1 also appears in LIST2.
Keywords supported: :test :test-not :key
(defvar l1 '(11 12 11 44 11 12 11 23))
(defvar l2 '(12 21 11 44 11 12 11 23))
(cl-subsetp l1 l2) ;; returns t
However there is a slight problem since it tests for the subset:
(defvar l3 '(12 21 11 44 11 12 11))
(cl-subsetp l3 l2) ;; returns t also
(and (cl-subsetp l3 l2)
(= (length l3) (length l2))) ;; should do
Alternatively there functions to test membership, so you could easily roll your
own little defun with 'member' or something else.
next prev parent reply other threads:[~2023-01-01 15:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-31 17:00 Finding repetitions of 8-tuples Hans Lonsdale
2023-01-01 15:13 ` Arthur Miller [this message]
2023-01-01 16:00 ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-01-01 16:39 ` Yuri Khan
2023-01-01 17:08 ` Hans Lonsdale
2023-01-01 15:16 ` Ruijie Yu via Users list for the GNU Emacs text editor
2023-01-01 15:38 ` Hans Lonsdale
2023-01-08 4:39 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM9PR09MB4977292E2D6088645EBE316C96F69@AM9PR09MB4977.eurprd09.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=hanslonsdale@mailfence.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).