From: Michael Heerdegen <michael_heerdegen@web.de>
To: Petteri Hintsanen <petterih@iki.fi>
Cc: Philip Kaludercic <philipk@posteo.net>, help-gnu-emacs@gnu.org
Subject: Re: Comparing lists
Date: Fri, 15 Sep 2023 04:12:42 +0200 [thread overview]
Message-ID: <87msxogp5x.fsf@web.de> (raw)
In-Reply-To: <x2mjzsu3wsl.fsf@iki.fi> (Petteri Hintsanen's message of "Wed, 13 Sep 2023 18:41:46 +0300")
Petteri Hintsanen <petterih@iki.fi> writes:
> seq-set-equal-p would fit the bill but does not seem to be recursive.
> For example:
>
> (seq-set-equal-p '(a b (c d)) '(a b (d c))) ⇒ nil
I think there is nothing in Emacs that matches your case exactly. The
map.el library comes close: your data has the form of nested
alists, i.e. nested maps, but there is no equality test for maps
implemented in that library.
Developers want to provide a "set.el" library in the future, but nobody
has started to write one so far.
If your data is always a nested alist with symbols as keys, I would try
to compare two data objects A and B efficiently like this:
- if not both A and B are `consp', compare using `equal' (no need for a
`proper-list-p' test I think)
- if they are both `consp' sort the elements in A and B using the
symbol names in the `car's as keys
- then you can sequentially compare the alist elements: all `cars'
should be `eq' and all `cdr's should be recursively equal, and no
alist should run out of elements before the other also runs out of
elements
If the data objects are really big, using hash tables might be better
than sorting.
Michael.
prev parent reply other threads:[~2023-09-15 2:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 18:53 Comparing lists Petteri Hintsanen
2023-09-12 7:26 ` Emanuel Berg
2023-09-12 12:19 ` Rudolf Schlatte
2023-09-13 15:32 ` Petteri Hintsanen
2023-09-13 10:34 ` Philip Kaludercic
2023-09-13 15:41 ` Petteri Hintsanen
2023-09-15 2:12 ` Michael Heerdegen [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87msxogp5x.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
--cc=petterih@iki.fi \
--cc=philipk@posteo.net \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.