From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: Output an alist from a function Date: Tue, 24 Sep 2024 17:04:20 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JqBn9C9eeGo7JQvC" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30424"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 24 17:05:13 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 1st76G-0007hy-SW for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 24 Sep 2024 17:05:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1st75X-0000Ri-Ih; Tue, 24 Sep 2024 11:04:27 -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 1st75V-0000RM-LG for help-gnu-emacs@gnu.org; Tue, 24 Sep 2024 11:04:25 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1st75T-0000Vx-Iq for help-gnu-emacs@gnu.org; Tue, 24 Sep 2024 11:04:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DWpXBr7DN1b29Nnk/KmMLr5/LRpkkeRDiwfIldNax0I=; b=MWlWvQbP5pIv2Zd7nlYtZspVfX THuhBlrQMx2JYdSrTzOFs04l0cV2xM2hJLcjb46GRMSB7VOC1z0A056bRRSkSCuA8mYwWBod9HnX7 NoB9sZxkbkmvMb7PWu+bn+SgMQggqunCyoTK1Xv6hMoKi8tt4uJ1BX12rNpvVcf5gAz/3L5wQt512 PQbxBrsy1xlDLFEeXtzOTzwAW5q3taEJxPSJCpm1Pdv7+3muoIFqCaEftc6G97BKNl7uhLgVXn6m4 /A7CQWjNXRZA3Vcba2gA2HDq8qGDFHuqvi5slCFR1yVHZdSCRiksW/QcThwzZP/PKZQAT8ZpDMGGu 6Zl0Vv9Q==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1st75Q-0003hE-0W; Tue, 24 Sep 2024 17:04:20 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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:148058 Archived-At: --JqBn9C9eeGo7JQvC Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 23, 2024 at 09:42:38PM +0000, Heime wrote: >=20 > I have an alist composed of keys and associated directory paths, and want= =20 > to output an alist made of the same keys with values being a validation f= lag. > Perhaps the problem is the call to mapcar. In the case of the hash table= I have > to call output-table after the maphash. >=20 > (defun dirpath-validation (input-table-or-alist) > "Test validity of directory path for each key." >=20 > (cond >=20 > ((hash-table-p input-table-or-alist) >=20 > ;; Make hash-table for output > (let ( (output-table (make-hash-table :test 'equal)) ) > (maphash (lambda (key dirpath) > (puthash key (not (file-directory-p dirpath)) output-t= able)) > input-table-or-alist) > output-table)) >=20 > (t > (mapcar (lambda (entry) > (let ( (key (car entry)) > (dirpath (cdr entry)) ) > (cons key (not (file-directory-p dirpath)))) ) > input-table-or-alist)) )) I've some difficulties figuring out what your question is. Is it that you want to write a function which "does the same" as output-table does, but for alist? Then we don't know what output-table does, so we can only guess. Assuming it writes its content into a buffer, each entry on one line, key and value separated by space, then this might do as a rough prototype: (insert (mapc (lambda (k v) (format "%s %s\n) k v) input-table-or-alist)) Cheers --=20 t --JqBn9C9eeGo7JQvC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZvLU7AAKCRAFyCz1etHa RvvvAJ9+kfd043sAikLaQIg1VW26/OvORgCdGFJ4O5wUfUVHCZt/vpxCRmkIlus= =5834 -----END PGP SIGNATURE----- --JqBn9C9eeGo7JQvC--