[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making alist that executes multiple commands
From: |
Stephen Berman |
Subject: |
Re: Making alist that executes multiple commands |
Date: |
Tue, 26 Nov 2024 00:11:09 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Mon, 25 Nov 2024 22:50:03 +0000 Heime <heimeborgia@protonmail.com> wrote:
> Sent with Proton Mail secure email.
>
> On Tuesday, November 26th, 2024 at 10:09 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>> On Mon, 25 Nov 2024 21:59:53 +0000 Heime heimeborgia@protonmail.com wrote:
>>
>> > About your comment
>> >
>> > > 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.
>>
>>
>> It produces all combinations of function calls comprised of one of the
>> functions f and one of the arguments a; I did not mean to imply anything
>> else. If it doesn't help with your use case, then of course don't use
>> it.
>
> I worked through it a little bit
>
> (dolist (f '(+ - list))
> (dolist (a '(1 2 3))
> (funcall f a)))
>
> Which fails for + and -, Elisp requires at least two arguments
> to perform arithmetic operations. Since only a single argument
> is provided, this will result in an error.
The functions `+' and `-' take any number of numbers (including none).
I don't know why you got an error; I don't:
(let (ret)
(dolist (f '(+ - list))
(dolist (a '(1 2 3))
(push (funcall f a) ret)))
ret)
==>
((3) (2) (1) -3 -2 -1 3 2 1)
[...]
> I just have a set of commands that I want to run according to some setting
> 'argm or 'go. Or do both with '(argm go). That's all. I think the lamdba
> gets this done. The arguments to any of the commands in the lambda can come
> from external settings as well right, global variables and can introduce
> conditionals as well. Which should be what I require. Or would you know
> about something else. Is there ways the implementation can break?
I already said if it does what you want, that's fine. I can't prove for
you it will always work, so if you find a case where it doesn't work,
feel free to show it. Until then, I think this discussion has run its
course.
Steve Berman
- Re: Making alist that executes multiple commands, (continued)
- 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/25
- Re: Making alist that executes multiple commands,
Stephen Berman <=
- Re: Making alist that executes multiple commands, Heime, 2024/11/26
- Re: Making alist that executes multiple commands, Stefan Monnier, 2024/11/24