From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: Check whether an object is an alist Date: Tue, 17 Sep 2024 19:20:22 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34138"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 17 21:21:26 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sqdlN-0008hv-Sm for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 17 Sep 2024 21:21:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqdkX-0006Yw-C8; Tue, 17 Sep 2024 15:20:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqdkU-0006Ww-G8 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2024 15:20:30 -0400 Original-Received: from mail-4319.protonmail.ch ([185.70.43.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqdkS-0003vU-FY for help-gnu-emacs@gnu.org; Tue, 17 Sep 2024 15:20:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1726600826; x=1726860026; bh=5tBfekYmrJkrJ0VF9BoQDHrWPDAtaMLDmVDQzJkfc68=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=ueZqLuo010rAhmHp6TnO5ldNdyacSaaXnRd02tNbdsLa7DGtAH75OahDQq5mz3ien AIP6wsfLX0Ta7eidRdCLvJ+4lVkh7Diu3ULlSRJ4qh2LiLvLYrA+zTnnHrj9sxzt/X ZAAgA0iNU2E9lfiWemMQAluCXXczk4NxoGpFwIJpq7YRmYWR6ni8KPu9ujCEYl9Tjk iE1nOxtL0Vj3BnW1iUOPB3fnXPKtK4ABa4jXQ9rl1TFs7HLUVDE6dADp1VWbsTLLnN /xFiYVLSGHhonqo+7MHPH8H+Qtd50BTaUlUymP1W74PuK5FfQqJ+XUCMoPl0GZ063l qMt522hGAif7w== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 9296970a6cae30aed465d642b3b1d486d976bb63 Received-SPF: pass client-ip=185.70.43.19; envelope-from=heimeborgia@protonmail.com; helo=mail-4319.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148014 Archived-At: On Wednesday, September 18th, 2024 at 6:28 AM, tomas@tuxteam.de wrote: > On Tue, Sep 17, 2024 at 06:04:41PM +0000, Heime wrote: >=20 > > On Wednesday, September 18th, 2024 at 5:57 AM, tomas@tuxteam.de tomas@t= uxteam.de wrote: >=20 > > > [...] as an exercise for the reader. > >=20 > > (cl-every #'consp '((foo . bar) nil (baz . quux))) >=20 >=20 > Yes. > -- > t Have done this small test, and even though there is a nil (or anything=20 else, e.g. jarod), assoc still works on the other keys. This means that=20 one can still be able to get correct values even if the object is not a complete alist. In a sense, if I am looking for keys in an object, even though it is not an alist in a strict sense, things might still work correctly. Is this the reason there does not exist an alistp ?=20 Or because traversing the list would be expensive ?=20 But if we want to be strict that an alist is a list of cons cells=20 with pairs of values, then only t1 should be accepted.=20 (let ( (t1 '((foo . bar) (alice . bob) (baz . qux))) (t2 '((foo . bar) nil (alice . bob) (baz . qux))) (t3 '((foo . bar) jarod (alice . bob) (baz . qux))) ) (message "%s" (assoc 'foo t1)) (message "%s" (assoc 'alice t2)) (message "%s" (assoc 'baz t3)) ) (foo . bar) (alice . bob) (baz . qux)