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:37:12 +0000 Message-ID: References: <87wmgr742q.fsf@rub.de> <87jzcr6ooe.fsf@rub.de> <87frnf6n2l.fsf@rub.de> <87bjy36m2w.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="7594"; 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 22:38:06 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 1tFgmT-0001sE-SZ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 22:38:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFglq-000376-AV; Mon, 25 Nov 2024 16:37:26 -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 1tFglo-00036i-HA for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:37:24 -0500 Original-Received: from mail-40132.protonmail.ch ([185.70.40.132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFgli-00037a-VN for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:37:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732570636; x=1732829836; bh=IBzxNblvPWZjFQjgCoLnENpCB/lA6HWMyO/tZUeO5lo=; 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=kzJ1n8iIPUJ6gecYhuAOU23mSDNaapmkRhPlNLgSJLIj1eWhvCHB+JwIjIYUdpM9/ 8dlxSWkjYtbnLQTXduP8tQDDeu8oFSXRTkjLWPE5RIC6LvliI5uYdVqbOyYOKpf1KD kDGl3x0xJKU/0r8icBwPRNtxC29qfry6/aQDu1GYb2sh0SiMzQGUtxf2KKGNJBdqkm h1LHtDy/DjVjppvtG+PIsfcQab3jn+2rMRAoFeWEs+u6sAN0wh0v6MRvJtH7IhoxGs k6FzYQK9jy6ni132+wOzrOQwQWqc/c9NrNDo3xicvpxPLIfwDOUFM+u6yUIYaPVmTH H6996BblWTuzg== In-Reply-To: <87bjy36m2w.fsf@rub.de> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 185c167fdea4f670c8971c76ca745763726a88e1 Received-SPF: pass client-ip=185.70.40.132; envelope-from=heimeborgia@protonmail.com; helo=mail-40132.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:148399 Archived-At: Sent with Proton Mail secure email. On Tuesday, November 26th, 2024 at 9:27 AM, Stephen Berman wrote: > On Mon, 25 Nov 2024 21:18:28 +0000 Heime heimeborgia@protonmail.com wrote= : >=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.com w= rote: > > >=20 > > > > > > Would be good to allow arguments to be freely combined. > > > > > > But how does one loop over lists of these arguments from the > > > > > > 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 lambd= a > > > > > expressions, where they are evaluated, as in the example you gave > > > > > previously. You can't use a function call as the first argument o= f > > > > > `apply' or` funcall' because a function call (which is just a lis= t 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 li= st, > > > > 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 wan= t > > > to combine the functions and arguments (e.g. if the functions don't a= ll > > > have the same arity), this could become complicated. But without > > > specific examples of what you want to do I can't give more specific > > > 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, and > > extensibility. Perhaps contrary to your original point of view? >=20 >=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 such > cases than looping over lists of functions and arguments. >=20 > Steve Berman For what reasons have you suggested looping over lists of functions and=20 arguments? Would that have a list of function names, and a list with=20 their arguments? You mentioned some advantages for working with arguments, but do not understand precisely what arguments to what were you referring to. With the lamdba version, I am getting the whole thing to work as intended.