From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Lists composed of equal number and kind of elements
Date: Tue, 28 Jul 2015 01:31:10 +0200 [thread overview]
Message-ID: <87egjt41q9.fsf@nl106-137-147.student.uu.se> (raw)
In-Reply-To: 55B5D99B.9080100@easy-emacs.de
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
next prev parent reply other threads:[~2015-07-27 23:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 7:11 Lists composed of equal number and kind of elements Andreas Röhler
2015-07-27 13:17 ` Drew Adams
2015-07-27 15:35 ` Andreas Röhler
2015-07-27 23:31 ` Emanuel Berg [this message]
2015-07-27 23:52 ` John Mastro
2015-07-27 23:55 ` Fwd: " John Mastro
2015-07-27 23:56 ` Emanuel Berg
[not found] ` <mailman.7498.1438041516.904.help-gnu-emacs@gnu.org>
2015-07-28 14:34 ` Barry Margolin
2015-07-28 21:11 ` Emanuel Berg
[not found] ` <mailman.7571.1438118111.904.help-gnu-emacs@gnu.org>
2015-07-28 21:37 ` Pascal J. Bourguignon
2015-07-29 2:16 ` Emanuel Berg
2015-07-29 7:21 ` Marcin Borkowski
2015-07-29 22:57 ` Emanuel Berg
2015-07-29 23:04 ` Emanuel Berg
[not found] ` <mailman.7584.1438136310.904.help-gnu-emacs@gnu.org>
2015-07-29 4:32 ` Pascal J. Bourguignon
2015-07-29 5:31 ` Rusi
2015-07-29 5:43 ` Pascal J. Bourguignon
2015-07-29 6:20 ` Rusi
2015-07-29 15:45 ` Pascal J. Bourguignon
2015-07-29 7:18 ` Marcin Borkowski
2015-07-29 10:06 ` Andreas Röhler
2015-07-29 22:45 ` Emanuel Berg
2015-07-28 1:07 ` Drew Adams
2015-07-28 21:10 ` Emanuel Berg
[not found] ` <mailman.7570.1438117959.904.help-gnu-emacs@gnu.org>
2015-07-28 21:34 ` Pascal J. Bourguignon
2015-07-28 21:37 ` Emanuel Berg
[not found] <mailman.7450.1437981102.904.help-gnu-emacs@gnu.org>
2015-07-28 17:10 ` Pascal J. Bourguignon
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=87egjt41q9.fsf@nl106-137-147.student.uu.se \
--to=embe8573@student.uu.se \
--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).