From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Making alist that executes multiple commands Date: Mon, 25 Nov 2024 21:59:53 +0000 Message-ID: References: <87jzcr6ooe.fsf@rub.de> <87frnf6n2l.fsf@rub.de> <87bjy36m2w.fsf@rub.de> <877c8r6l8e.fsf@rub.de> Reply-To: Heime 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="13946"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 25 23:00:37 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 1tFh8H-0003P9-CX for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 23:00:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFh7l-0005k7-Uy; Mon, 25 Nov 2024 17:00:05 -0500 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 1tFh7k-0005jf-KU for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 17:00:04 -0500 Original-Received: from mail-43167.protonmail.ch ([185.70.43.167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFh7i-0006L7-3W for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 17:00:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732571997; x=1732831197; bh=5qPlxzSRf2Iwn8+fZ1/r4iUx9orkkPwc/DPJXV0AzD4=; 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:List-Unsubscribe:List-Unsubscribe-Post; b=qdHNBUnVdOXwQjmKP7sccBhxfFNykDTdA8IWxfreKcTK+KjOrXA1dmAjYk1gHI8xz p6x53AHsTAA0xEWU3auFwJ6iq8l+wXpKmKui9FaHtSF5bL+2bqPxEK5DV9BWLbQXTw 284M/OIrD+1B9bY0LytiXUpj+CbZyhhGiAfhMr7PCROf1vpnFuHL1HkGOHVYkftyJq WAFrYDHRtIPqVArYB+OFdUV2rQsbtoJZIVKPxTKF7dVmqnd0Dm4dYL/kxhsSfo1Z7L F8KzoCmSLj73ROoiDMmMvzl6fa2b3iJ/14b0sDDOZSfVRKlLgJGbReL1L3vLAYLBUu pV9F/xJwRmnrw== In-Reply-To: <877c8r6l8e.fsf@rub.de> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: a51f2c64b1408a75a221bf76e43a4ca097b53ef3 Received-SPF: pass client-ip=185.70.43.167; envelope-from=heimeborgia@protonmail.com; helo=mail-43167.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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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:148401 Archived-At: Sent with Proton Mail secure email. On Tuesday, November 26th, 2024 at 9:45 AM, Stephen Berman wrote: > On Mon, 25 Nov 2024 21:37:12 +0000 Heime heimeborgia@protonmail.com wrote= : >=20 > > Sent with Proton Mail secure email. > >=20 > > On Tuesday, November 26th, 2024 at 9:27 AM, Stephen Berman > > stephen.berman@gmx.net wrote: > >=20 > > > On Mon, 25 Nov 2024 21:18:28 +0000 Heime heimeborgia@protonmail.com w= rote: > > >=20 > > > > Sent with Proton Mail secure email. > > > >=20 > > > > On Tuesday, November 26th, 2024 at 9:05 AM, Stephen Berman > > > > stephen.berman@gmx.net wrote: > > > >=20 > > > > > On Mon, 25 Nov 2024 20:45:22 +0000 Heime heimeborgia@protonmail.c= om wrote: > > > > >=20 > > > > > > > > Would be good to allow arguments to be freely combined. > > > > > > > > But how does one loop over lists of these arguments from th= e > > > > > > > > code you posted? > > > > > > >=20 > > > > > > > Something like this, for example: > > > > > > >=20 > > > > > > > (dolist (f '(+ - list)) > > > > > > > (dolist (a '(1 2 3)) > > > > > > > (funcall f a))) > > > > > > >=20 > > > > > > > > I could have the following, but got some difficulties about > > > > > > > > how to execute each command with its arguments, in the way = you > > > > > > > > suggest. > > > > > > > >=20 > > > > > > > > (defun fpln-test (symbol-list) > > > > > > > > (let ( (lookup-alist '((ar ((alkotr-ar arg-this) > > > > > > > > (alkotr-af arg-that arg-other))) > > > > > > > > (go ((alkotr-go arg-dim) > > > > > > > > (alkotr-gc arg-dum arg-sum))) )) ) > > > > > > > >=20 > > > > > > > > (dolist (actm symbol-list) > > > > > > > > (let ((commands (cdr (assoc actm lookup-alist)))) > > > > > > > > (while commands > > > > > > > > (dolist (cmd commands) > > > > > > > > (apply (car cmd) (cdr cmd))) > > > > > > > > (message "Key '%s' not found in lookup-alist" key)))))) > > > > > > >=20 > > > > > > > When I wrote "using a list of function calls as the value of = each alist > > > > > > > element seems reasonable" I was assuming you wanted them in l= ambda > > > > > > > expressions, where they are evaluated, as in the example you = gave > > > > > > > previously. You can't use a function call as the first argume= nt of > > > > > > > `apply' or` funcall' because a function call (which is just a= list whose > > > > > > > first element is a function) is not a function. > > > > > >=20 > > > > > > Have been trying to handle your suggestion not to use a lambda,= but to > > > > > > handle the general case of executing a sequence of commands in = a list, > > > > > > each element being a command to run. > > > > >=20 > > > > > Then you might try looping over lists of functions and arguments = like in > > > > > the above schematic example I gave, though depending upon how you= want > > > > > to combine the functions and arguments (e.g. if the functions don= 't all > > > > > have the same arity), this could become complicated. But without > > > > > specific examples of what you want to do I can't give more specif= ic > > > > > advice. > > > >=20 > > > > I have a sequence of commands for setting up a library component > > > >=20 > > > > For instance > > > >=20 > > > > ;; For option 'armg > > > > (add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN")) > > > > (require 'napyon) > > > >=20 > > > > and > > > >=20 > > > > ;; For option 'go > > > > (napyon 'go) > > > >=20 > > > > Using lambda seems to offer more flexibility and maintainability, a= nd > > > > extensibility. Perhaps contrary to your original point of view? > > >=20 > > > Well, these examples suggest that you indeed want different arguments > > > for each function, and moreover have groups of function calls, so yes= , > > > lambda forms work well for those, and they are probably simpler for s= uch > > > cases than looping over lists of functions and arguments. > > >=20 > > > Steve Berman > >=20 > > For what reasons have you suggested looping over lists of functions and > > arguments? Would that have a list of function names, and a list with > > their arguments? > >=20 > > You mentioned some advantages for working with arguments, but do not > > understand precisely what arguments to what were you referring to. >=20 >=20 > I mentioned freely combining functions and arguments and gave a > schematic example with nested dolist's; I haven't given it more thought > than that. >=20 > > With the lamdba version, I am getting the whole thing to work as intend= ed. >=20 >=20 > Then be happy and continue to use it! >=20 > Steve Berman About your comment=20 > That seems fine if the functions take no arguments, though probably not > as flexible as looping over a list. You provided the examples (funcall 'alkotr-ar ar) (funcall 'alkotr-ar af) But I did not understand how to inceorporate this idea. With my lambda function, I can also pass arguments to my commands. I did not understand the implication of the following in my case. (dolist (f '(+ - list)) (dolist (a '(1 2 3)) (funcall f a))) Thusly, I do not understand what "allow arguments to be freely combined" actually means practically.