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: Hans Lonsdale
Subject: Re: Finding repetitions of 8-tuples
Date: Sun, 1 Jan 2023 18:08:53 +0100 (CET)


> ----------------------------------------
> From: Yuri Khan <yuri.v.khan@gmail.com>
> Sent: Sun Jan 01 17:39:36 CET 2023
> To: Arthur Miller <arthur.miller@live.com>
> Cc: Hans Lonsdale <hanslonsdale@mailfence.com>, Help Gnu Emacs 
> <help-gnu-emacs@gnu.org>
> Subject: Re: Finding repetitions of 8-tuples
> 
> 
> On Sun, 1 Jan 2023 at 22:19, Arthur Miller <arthur.miller@live.com> wrote:
> 
> > > 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?
> 
> This line of thought leads nowhere because treating a list as a set
> ignores its duplicate counts. I take it that in the OP’s problem
> statement (1 1 1 1 1 2 2 2) is to be considered distinct from (1 1 1 1
> 2 2 2 2), but, treated as sets, they are both equivalent to (1 2). The
> original problem calls for multisets — containers where the order is
> not significant but the counts of duplicates are.

That's correct.
 
> Sorting each list and comparing the result of sorting, as suggested in
> another reply, is going to be a better approach.

Agreed
 
> Alternatively, one might hash each element and xor the hashes
> together. However, this carries collision risk inherent in hash-based
> solutions — if hashes are different, the multisets are different, but
> if the hashes are equal, this does not guarantee the equality of
> multisets.
> 


-- 
Sent with https://mailfence.com  
Secure and private email



reply via email to

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