help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding repetitions of 8-tuples


From: Ruijie Yu
Subject: Re: Finding repetitions of 8-tuples
Date: Sun, 01 Jan 2023 10:00:26 -0600
User-agent: mu4e 1.8.13; emacs 30.0.50

Arthur Miller <arthur.miller@live.com> writes:

> 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

I looked around and found out that `seq-set-equal-p' might be more
suitable for this task: this function performs a set-equality check
between the two lists (or, more broadly, sequences) whereas `cl-subsetp'
checks for subsets, as you have noted later in your message.

> [...]

Best,


RY



reply via email to

[Prev in Thread] Current Thread [Next in Thread]