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: Output an alist from a function Date: Wed, 25 Sep 2024 20:30:30 +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="33206"; 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 Wed Sep 25 22:31:19 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 1stYfP-0008Um-R8 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 25 Sep 2024 22:31:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stYeq-00046y-Vv; Wed, 25 Sep 2024 16:30:45 -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 1stYeo-00046e-Iu for help-gnu-emacs@gnu.org; Wed, 25 Sep 2024 16:30:42 -0400 Original-Received: from mail-4325.protonmail.ch ([185.70.43.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1stYem-00053s-DW for help-gnu-emacs@gnu.org; Wed, 25 Sep 2024 16:30:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1727296235; x=1727555435; bh=W7wID76a2MBSA+Bl2c9OIGu24pNrkteEGsMREq+7YCA=; 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=enKKltWQlldxig/zIajcg41QCVpw4cSQFFCL/ZQQAC3D7WD21P0RNmdaoUCvd7IUA +dHO0LKRP5SR6Dq5lH+4D3w3XT7DZir92AXmE6bfHNOQYwh7nic+XW56earjR+37Mh bIMOPzgQUQefBPOr4MKylci8MtSq9OJR9Vxh9dYhe68qUO4hhzCaLAlLQvVwlNpYp9 /ehkSH7Sb19evzLmLpzeEiu/eRlOGPUyPr6ZFLTlyKmmYoe2GA61B1BRuH4ClRG2br 86PaiyLu/0XrEBARWLvnMkgKpvbrqtH9QbyjLD/vWtbajo4LEvBwBiUSWG0JR04WZd eI+wLggDrVCyw== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 979726fe4c5ea606d731ede4b22802ec789cd5a0 Received-SPF: pass client-ip=185.70.43.25; envelope-from=heimeborgia@protonmail.com; helo=mail-4325.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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:148067 Archived-At: Sent with Proton Mail secure email. On Wednesday, September 25th, 2024 at 4:39 PM, tomas@tuxteam.de wrote: > [I have re-added the mailing list in the CC] >=20 > On Tue, Sep 24, 2024 at 09:28:24PM +0000, Heime wrote: >=20 > > On Wednesday, September 25th, 2024 at 3:04 AM, tomas@tuxteam.de tomas@t= uxteam.de wrote: >=20 >=20 > [...] >=20 > > > I've some difficulties figuring out what your question is. > > >=20 > > > Is it that you want to write a function which "does the same" > > > as output-table does, but for alist? > >=20 > > Precisely. The function for hash tables accepts a hash table as input > > and outputs another hash table, where the keys correspond to directory > > validation flags. I use maphash to iterate over the elements, and after > > constructing the new table during the loop, I retrieve and return the > > output-table after maphash completes. > >=20 > > Similarly, in the case of alists, the function takes an alist (where > > each element is a key paired with a directory path) and returns a new > > alist, where each key is associated with its respective directory > > validation flag. This mirrors the behavior of the hash table > > implementation but uses alists instead. > >=20 > > Currently, I am using mapcar to iterate over the alist and apply the > > transformation via a lambda function. However, I am uncertain whether > > simply invoking mapcar is enough to ensure the same structured output a= s > > with hash tables. >=20 > > With hash tables, maphash alone wasn=E2=80=99t sufficient - I needed to > > explicitly construct and return an output hash table within the > > function. My question is whether the same principle applies for alists: > > do I need to construct and store the output alist in a temporary > > structure, and then explicitly return it, akin to how I do with > > output-table in the hash table case ? >=20 >=20 > I'd, (once again) refer you to the corresponding function documentations: > Mapcar collects the results of the function calls into a new list (if > that function returns pairs, as yours does, you end up with an alist). >=20 > Maphash "just" iterates over the key-value pairs. The naming is a bit > inconsistent, yes. Recognize the flaws in this school of thought. While it is acknowledged that inconsistencies exist, the proposed solution is always to read more documentation and conduct small experiments to figure things out independently. This approach is highly inefficient, as it fails to address the root inconsistencies. If these inconsistencies remain unresolved, external assistance becomes far more critical than merely persisting with an incoherent system in the hope of some sudden breakthrough. > BTW: there is a function which "just" iterates over a list, "mapc". You > see it in the code snippet I gave you. You use that one when you'd throw > away the resulting list of "mapcar". >=20 > I'd recommend to read more docs and to make little experiments (i.e. > small programs of one, two or three lines) to check your understanding > of what you have read. >=20 > I see you stumbling time and again over very basic things, and you'd have > far less busywork if you had those basic things at your disposal. >=20 > Cheers > -- > t