From: tomas@tuxteam.de
To: Heime <heimeborgia@protonmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Check whether an object is an alist
Date: Tue, 17 Sep 2024 13:23:17 +0200 [thread overview]
Message-ID: <ZulmpRlMk7iPInt0@tuxteam.de> (raw)
In-Reply-To: <5ta65eMG2v0q4BbBDFQ5D7JUEXbXaBCpR3DOxm2lsGJpx-9k04kvX-UFtQTaKRvUEK6Pi7vP2q_0JrADs7MB8JIL4jzAZFEQHQf1enrBLtM=@protonmail.com>
[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]
On Tue, Sep 17, 2024 at 11:16:24AM +0000, Heime wrote:
>
>
>
>
>
> Sent with Proton Mail secure email.
>
> On Tuesday, September 17th, 2024 at 9:46 PM, tomas@tuxteam.de <tomas@tuxteam.de> wrote:
>
> > On Tue, Sep 17, 2024 at 11:38:46AM +0200, Manuel Giraud via Users list for the GNU Emacs text editor wrote:
> >
> > > Heime heimeborgia@protonmail.com writes:
> > >
> > > > Sent with Proton Mail secure email.
> > > >
> > > > On Monday, September 16th, 2024 at 10:29 PM, Heime heimeborgia@protonmail.com wrote:
> > > >
> > > > > Is there a function that checks whether an object is an alist.
> > > > > Have only found listp.
> > > >
> > > > Because I may have to come up with a solution, I have made this one.
> > > > Am I missing anything ?
> > > >
> > > > (defun torium-alist-p (obj)
> > > > "Return t if object OBJ is an association list (alist)."
> > > > (and (listp obj)
> > > > (not (null obj))
> > > > (every (lambda (x)
> > > > (and (consp x)
> > > > (not (null x))))
> > > > obj)))
> > >
> > > Looks good to me. I think it should `cl-every' instead of` every' and
> > > also, maybe, nil is a valid empty alist.
> >
> >
> > Unless you'd like to have nil as a possible key (alists allow that,
> > why not?):
> >
> > (setq al '((nil . "I am not") (t . "I am")))
> > (alist-get nil al)
> > => "I am not"
Oh, wait. I just see you were checking the pair to be not
null. Then it's easier: your above code seems right, just
the (not (null x)) is superfluous, since (consp x) makes
sure it is so.
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2024-09-17 11:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 10:29 Check whether an object is an alist Heime
2024-09-17 8:45 ` Heime
2024-09-17 9:38 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-09-17 9:46 ` tomas
2024-09-17 11:16 ` Heime
2024-09-17 11:23 ` tomas [this message]
2024-09-17 13:51 ` Heime
2024-09-17 13:58 ` tomas
2024-09-17 14:32 ` Heime
2024-09-17 15:20 ` tomas
2024-09-17 16:26 ` Heime
2024-09-17 17:57 ` tomas
2024-09-17 18:04 ` Heime
2024-09-17 18:28 ` tomas
2024-09-17 19:20 ` Heime
2024-09-17 19:35 ` tomas
2024-09-17 21:02 ` Heime
2024-09-17 21:25 ` Heime
2024-09-18 4:21 ` tomas
2024-09-18 4:52 ` Heime
2024-09-17 22:01 ` Stephen Berman
2024-09-17 19:22 ` [External] : " Drew Adams
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=ZulmpRlMk7iPInt0@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=heimeborgia@protonmail.com \
--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.
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.