[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making alist that executes multiple commands
From: |
Heime |
Subject: |
Re: Making alist that executes multiple commands |
Date: |
Mon, 25 Nov 2024 20:45:22 +0000 |
> > 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 alist
> 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 to
handle the general case of executing a sequence of commands in a list,
each element being a command to run.
> On Mon, 25 Nov 2024 17:59:22 +0000 Heime heimeborgia@protonmail.com wrote:
>
> > I get error when calling (marnap '(armg go))
> >
> > That is I get message "ACTM Unrecognised: 'armg"
> >
> > (defun marnap (&optional actm-service)
> >
> > (let ( (lookup-alist '((armg ((add-to-list 'load-path
> > (marnap-sec-fpln-waypt "NAPLN"))
> > (require 'napyon)))
> >
> > (go ((napyon 'go))) )) )
> >
> > (dolist (actm actm-service)
> > (let ((fnlist (cdr (assoc actm lookup-alist))))
> > (while fnlist
> > (dolist (cmd fnlist)
> > (if (functionp (car cmd))
> > (apply (car cmd) (cdr cmd))
> > (message "ACTM Unrecognised: '%s\n" actm)))))) ))
>
>
> This is for the same reason as above: the first invocation of `(car cmd)'
> returns` (add-to-list 'load-path (marnap-sec-fpln-waypt
> "NAPLN"))', which is a function call, not a function.
>
> Steve Berman
Have put another question to not complicate this discussion.
Would it make sense to execute the function calls with eval.
Still that is also giving me problems with
(invalid-function (add-to-list 'load-path (marnap-sec-fpln-waypt "NAPLN")))
- Re: Making alist that executes multiple commands, (continued)
- Re: Making alist that executes multiple commands, Heime, 2024/11/24
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/24
- Re: Making alist that executes multiple commands, Heime, 2024/11/24
- Re: Making alist that executes multiple commands, Heime, 2024/11/24
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands,
Heime <=
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/25
- Re: Making alist that executes multiple commands, Stephen Berman, 2024/11/25
- Re: Making alist that executes multiple commands, Heime, 2024/11/26