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:27:19 +0100 Message-ID: <87bjy36m2w.fsf@rub.de> References: <87mshn8xd8.fsf@gmx.net> <87wmgr742q.fsf@rub.de> <87jzcr6ooe.fsf@rub.de> <87frnf6n2l.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="6187"; 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:27:56 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 1tFgcd-0001Rx-Ue for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Nov 2024 22:27:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFgcC-00081L-Sf; Mon, 25 Nov 2024 16:27:29 -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 1tFgcA-000816-Op for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:27:26 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFgc8-0001lQ-B6 for help-gnu-emacs@gnu.org; Mon, 25 Nov 2024 16:27:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1732570041; x=1733174841; i=stephen.berman@gmx.net; bh=VIHIJmJOsQ5bKBCzZq6mfyzQsWKbEe+bwnAQThZhywc=; 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=pY48hjKZSqV7AeVFZblCCU6YYw18Gd2d7CRSgYpqPcOEHZXV1CtYOVShS+3aozx0 IfmoHjFoCR+cvU5nNMRzLwzI1BJM9IIdXunsp2et7eXufzFTFvS3WE7He2IyshWtu qTwLz+Pyt9ySiqAj5zePTpzzjKYqHLA3Or0h1fqRNO15hVutNbVGqeQYJTmCThSNu dmix7OQsxOgDSebN8XAsBSzgUW+5GTTjWA9VaExCPi1mQVZEzdZInXxTCXDSskMZI 4PYG5eb8v55aAMeLzLkRvjDZGVoYVkpheZLR/rQpoXSWyjmM+yDQUSxcWpZjIhDjM YWHW3UZaKPdPxw8pRA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.50.169]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MDysg-1tNM6u43LY-00036L; Mon, 25 Nov 2024 22:27:21 +0100 In-Reply-To: (Heime's message of "Mon, 25 Nov 2024 21:18:28 +0000") X-Provags-ID: V03:K1:QJ7zOo0gi+XmDWd4ycsobpsg5C1kD3osMJpzmj+UETbjXOl5Q8h j8ZvMVOEyCcy2ITMFzjkGLMZY9kCLCyuc1VBV4ethmKDpIlMnWPrg+lB7WSPviMBrA7DBYu o5cN8ISDAbvYHFanjdD+TBDfvjt+QSGd+5FyA/V2RHY2SiJNlcJ0EmFiPP1DsW9z8bCTbHu HrhvrGQSYTbU1f+h0qzFg== UI-OutboundReport: notjunk:1;M01:P0:ZlUeba0b+Qc=;dc2VOqem+H9dlH1KR5849tYr5ma 5QSJe1gPfcud679Y8qAYqHBpCYUFVWRlDEjQ2YqOxjdpCBBRQ8kN9NYjn6WlBiny5FULDs2+k codzq1ZZJGYpRJpKpKPVynW+M6zCsWVk+3nlneTVL1IJRN418G41HipcNVPRyCGMtilUIhYv5 e7nijsJwoPru8YzATPyfKMvAO1zoPDO2pFcAoR3RSMNIXdTn8CMDf1y6xxBdCDHSNLrm2SxQn Ei6nzBw4bNDZlq6bas5JyOtzLHz4s3XfaD3T2yxrnBnmOD0Tcf8J22PS3hi/0GXvB0ha8TGLg 0rPk2lTBphbJXJWjArBnwSo93tVWTOD3/yHPIqlrt0IrkxYpc5mKRPnJT7Miv/Lf8jPiEPV/m BxapArtJep/T67AZhuPLNQ+nuv4YF0iNSZXiAaMIaWpyapmruVIL62C1vqvbL+/r2XABA9bM1 FenTMv+aD95uNw7P//p2wfgMQ1MxK7/KGBaMw99vchVYUFU4Bslhvf6WE1gwdWu3oZF5HpIbZ Qy7+zWxNf/ioF28Q2/p9+69zG3ICQSJXKBZcXtKpzr+gwlcVJKQfrUPbrvVq+lfxrFU4H5z2+ f+aC+5dw4zc3GvJl3bPSPp8UFjDJKmT59U/yXZd8VNvCBhI/vErfjKpp8QicI4221Dv1fuB1W A3XceVWIBynJ/0QJuB97/ZOMdG+XnAZBXpmKhpvkM2ny/Vu2Uq3tcgBwbm/Jl8q/eR7Uw1KHp YOKGbuKZYsuzBbpCG8CFkewzVCy8W+mN0FaddLyDeJkbIZHfpHRxdbo51zgNAJrSWRT+OwHq Received-SPF: pass client-ip=212.227.15.15; 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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:148398 Archived-At: On Mon, 25 Nov 2024 21:18:28 +0000 Heime wrot= e: > Sent with Proton Mail secure email. > > On Tuesday, November 26th, 2024 at 9:05 AM, Stephen Berman > wrote: > >> On Mon, 25 Nov 2024 20:45:22 +0000 Heime heimeborgia@protonmail.com wro= te: >> >> > > > 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 you >> > > > 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 each a= list >> > > element seems reasonable" I was assuming you wanted them in lambda >> > > expressions, where they are evaluated, as in the example you gave >> > > previously. You can't use a function call as the first argument of >> > > `apply' or` funcall' because a function call (which is just a list = whose >> > > first element is a function) is not a function. >> > >> > Have been trying to handle your suggestion not to use a lambda, but t= o >> > 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 like i= n >> 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 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 such cases than looping over lists of functions and arguments. Steve Berman