[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lists composed of equal number and kind of elements
From: |
Emanuel Berg |
Subject: |
Re: Lists composed of equal number and kind of elements |
Date: |
Tue, 28 Jul 2015 01:31:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> is there a handy way to check if two lists --results
> of (window-list) precisely-- are equal WRT to the
> kind and number elements?
>
> The order of elements should be ignored.
A list where you don't care about the order of the
elements is a *set*. (In the abstract sense, a set
doesn't have an order.) This is from the world of
set theory, and relational algebra; and it is all
easily illustrated with Venn diagrams which people
might remember from throwing rocks as kids and then
drawing circles to indicate territorial advances.
If the order do count in a list, the interpretation is
there is size and direction but no position - i.e.,
we have a *vector*. Not surprisingly Emacs has that
implemented in yet another way (because Emacs exists
in the domain which I have fondly nicknamed
"reality"). This however is in the world of
linear algebra. The interesting thing about this field
of mathematics, is that it is actually useful!
GPS works with several satellites sending information
as vectors and then you have it put together in
a matrix where any incorrect reading will be
canceled out by the "redundant" correct information!
Anyway, to answer your question, try this:
(defun set-equal (list-1 list-2)
(and (null (cl-set-exclusive-or list-1 list-2))
(= (length list-1)
(length list-2)) ))
Note: Depending what is deemed faster and/or more
likely to tell the correct state, the order of the
`and' arguments could be reversed...
--
underground experts united
http://user.it.uu.se/~embe8573
- Lists composed of equal number and kind of elements, Andreas Röhler, 2015/07/27
- RE: Lists composed of equal number and kind of elements, Drew Adams, 2015/07/27
- Re: Lists composed of equal number and kind of elements,
Emanuel Berg <=
- Re: Lists composed of equal number and kind of elements, John Mastro, 2015/07/27
- Fwd: Lists composed of equal number and kind of elements, John Mastro, 2015/07/27
- Re: Lists composed of equal number and kind of elements, Emanuel Berg, 2015/07/27
- Message not available
- Re: Lists composed of equal number and kind of elements, Barry Margolin, 2015/07/28
- Re: Lists composed of equal number and kind of elements, Emanuel Berg, 2015/07/28
- Message not available
- Re: Lists composed of equal number and kind of elements, Pascal J. Bourguignon, 2015/07/28
- Re: Lists composed of equal number and kind of elements, Emanuel Berg, 2015/07/28
- Re: Lists composed of equal number and kind of elements, Marcin Borkowski, 2015/07/29
- Re: Lists composed of equal number and kind of elements, Emanuel Berg, 2015/07/29
- Re: Lists composed of equal number and kind of elements, Emanuel Berg, 2015/07/29