From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Making alist that executes multiple commands Date: Mon, 25 Nov 2024 22:45:37 +0100 Message-ID: <877c8r6l8e.fsf@rub.de> References: <87wmgr742q.fsf@rub.de> <87jzcr6ooe.fsf@rub.de> <87frnf6n2l.fsf@rub.de> <87bjy36m2w.fsf@rub.de> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37079"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) 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 Mon Nov 25 22:46:22 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 1tFguU-0009VQ-1I for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 22:46:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFgtv-0003qe-0l; Mon, 25 Nov 2024 16:45:47 -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 1tFgts-0003qV-NU for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:45:44 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFgtq-0004QX-Fx for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:45:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1732571138; x=1733175938; i=stephen.berman@gmx.net; bh=TPfrLf7sUiSl6x3LpOBT8LW56eqYXF1CIovXi+XGnrk=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=OT0cQt+Z+by4CHRigjHhaBnxN8owNC4t0mznLzypTU++oHXL5Mo8vtIMiRMkgx7d zd8Gf6efCk6HO0vBdkxcJtxAY73MSxR5mu7lNaYGMVm9G8Cz8gofGVdKu40ZX1/eO Y1JtR+5JovuRD4+Q1De3V87fCXSUXh4FHIO6UHPDz+hT2i6jr4C9sYIVYESFQvnZP uunS/Hhq5JTPXs03LGJMw0s+jxJnux6/h76lZz9Tznd1NMQC7pZXVptyReZM0uZfn N0vPTZbE8G6KvNCanzDaxjM8xclOByW9NB10H1tfKAwLtcaorKOJSAecI83MwPgJz pyGStqA/WgqeG9TriA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.50.169]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mnpru-1u4ezI1278-00qfjh; Mon, 25 Nov 2024 22:45:38 +0100 In-Reply-To: (Heime's message of "Mon, 25 Nov 2024 21:37:12 +0000") X-Provags-ID: V03:K1:HLDwog7mjgYWM9IFaGdC3Q1FDmZ9n6QvjOlItho2KVPHFnmcOAX c1EXJvCt+ohvi+3vjXsf+lZeMfkuYJWQiXI9E3eoD1BMeH2ZIRm9/jvu65whpVe4ko4nSjv 5oTEMeXHn/mhubM17FK37EJCMzIPmaKBxfhVFOLXjAMPxPGmzcviWgN8fRfUAue8QN1Kb4j QL2ePJCs/P3dN/op/oRHw== UI-OutboundReport: notjunk:1;M01:P0:7Q0aUCgRshU=;RqgmGtbp6i9k45p9j4XQG+q1DYL pivuLKngIhgGN8lua3h9BOXOlQLw2IG+Km2/FBuCba4o91+uhnKHF77oQ/5aacEXvA3+d64hU BD1gx/roJwz5lrkYywn3TMH7kcAkPHn08xQ9ATsjoQH/dNYQt+3e1DRSZiG3Da1z1oHXgjDaJ 7DqgJzchFVtMlgBMCueMGfUtKorHTkTX2J6iqEKusjzR+LEch9rIZX23cvbhK6fPvvCeoXfpY APCnzOIMiIQSciJ1GwANHrqF57EhmXjsoyjppMmmplY54Ogz9ysJ6HvgpmfBgvtNeNQFaeRTt fjQPoFJSECfExHkFlsAXKBs10rqhMybjlczGO4/X6DKl8ui2CJ9qeGcp8HiT2d3jAMeQWta1m mg9WudQUUHhohfFVxGNEuzEmVV4iAsxu/JDG7BTx2aHWB2bHxrV5pHO/bjIf2MDT5lV8A2NHD Qerjll9Lw87xBpebzudAoYa7c+QQOHbMfMBb6VGXjxijU81puJ6wIbwdl9EjYxqOpjaQn9CSS IKuzHKIvnatq6R3UlCNLl5NXiR0yO4S/w2EHBYCCcz09IMXLx6OBnoEutSlP0e2xww7NabHeO EUHNN9RxO0+UzqoCxDZ7W066GqSXakwy+t7sEmTLmfEQpDnnhXQoA8Yi0W0402/e1Tmcn4S8h xz3vsVZz+qg7S4lcRJt1BAMAlvM79rplHE0+lTfqKxEns2L5tsCh+7YHH5kQrrCE8l6lhBv93 XNfUffjZhHFGqersTrwpie1vyz1W9n39CfcRe4vSZoKEO+zeLbW8PsnohwqOBLV5F/l2VAtx Received-SPF: pass client-ip=212.227.17.21; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:148400 Archived-At: On Mon, 25 Nov 2024 21:37:12 +0000 Heime wrot= e: > 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 wro= te: >> >> > Sent with Proton Mail secure email. >> > >> > On Tuesday, November 26th, 2024 at 9:05 AM, Stephen Berman >> > stephen.berman@gmx.net wrote: >> > >> > > On Mon, 25 Nov 2024 20:45:22 +0000 Heime heimeborgia@protonmail.com= wrote: >> > > >> > > > > > 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? >> > > > > >> > > > > Something like this, for example: >> > > > > >> > > > > (dolist (f '(+ - list)) >> > > > > (dolist (a '(1 2 3)) >> > > > > (funcall f a))) >> > > > > >> > > > > > I could have the following, but got some difficulties about >> > > > > > how to execute each command with its arguments, in the way yo= u >> > > > > > suggest. >> > > > > > >> > > > > > (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))) )) ) >> > > > > > >> > > > > > (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)))))) >> > > > > >> > > > > When I wrote "using a list of function calls as the value of ea= ch alist >> > > > > element seems reasonable" I was assuming you wanted them in lam= bda >> > > > > expressions, where they are evaluated, as in the example you ga= ve >> > > > > previously. You can't use a function call as the first argument= of >> > > > > `apply' or` funcall' because a function call (which is just a l= ist whose >> > > > > first element is a function) is not a function. >> > > > >> > > > Have been trying to handle your suggestion not to use a lambda, b= ut to >> > > > handle the general case of executing a sequence of commands in a = list, >> > > > each element being a command to run. >> > > >> > > Then you might try looping over lists of functions and arguments li= ke in >> > > the above schematic example I gave, though depending upon how you w= ant >> > > 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 specific >> > > advice. >> > >> > I have a sequence of commands for setting up a library component >> > >> > For instance >> > >> > ;; For option 'armg >> > (add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN")) >> > (require 'napyon) >> > >> > and >> > >> > ;; For option 'go >> > (napyon 'go) >> > >> > Using lambda seems to offer more flexibility and maintainability, and >> > extensibility. Perhaps contrary to your original point of view? >> >> >> 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 suc= h >> cases than looping over lists of functions and arguments. >> >> Steve Berman > > 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? > > You mentioned some advantages for working with arguments, but do not > understand precisely what arguments to what were you referring to. 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. > With the lamdba version, I am getting the whole thing to work as intende= d. Then be happy and continue to use it! Steve Berman