From: Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Making alist that executes multiple commands
Date: Tue, 26 Nov 2024 08:46:13 +0000 [thread overview]
Message-ID: <mM1gx1R98Rg729aq4w5spxd_fG64-_mvUJ8sicqOZM9eWjcJK_NBoXMFvHEsmnQhFcCaGpct7la_AJ7S20bbzE70fRshAzvjw8jtFZ6xUEQ=@protonmail.com> (raw)
In-Reply-To: <87y1166h9u.fsf@rub.de>
Sent with Proton Mail secure email.
On Tuesday, November 26th, 2024 at 11:11 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> 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)
You are quite right. I saw nil and thought it failed. It did not
after doing
(dolist (f '(+ - list))
(dolist (a '(1 2 3))
(message "Result of %s: %s" f (funcall f a )) ))
> [...]
>
> > 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
Right, I now understand the mixing of list of arguments with a list
of function names. Such mixing is not what I had in mind. Just wanted
a set a commands in a function which is not defined externally.
next prev parent reply other threads:[~2024-11-26 8:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-24 21:51 Making alist that executes multiple commands Heime via Users list for the GNU Emacs text editor
2024-11-24 22:56 ` Stephen Berman
2024-11-24 23:13 ` Heime via Users list for the GNU Emacs text editor
2024-11-24 23:28 ` Stephen Berman
2024-11-24 23:39 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 1:05 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 9:40 ` Stephen Berman
2024-11-25 13:10 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 14:58 ` Stephen Berman
2024-11-25 16:36 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 17:59 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 20:31 ` Stephen Berman
2024-11-25 20:45 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 21:05 ` Stephen Berman
2024-11-25 21:18 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 21:27 ` Stephen Berman
2024-11-25 21:37 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 21:45 ` Stephen Berman
2024-11-25 21:59 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 22:09 ` Stephen Berman
2024-11-25 22:50 ` Heime via Users list for the GNU Emacs text editor
2024-11-25 23:11 ` Stephen Berman
2024-11-26 8:46 ` Heime via Users list for the GNU Emacs text editor [this message]
2024-11-25 3:00 ` Stefan Monnier via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='mM1gx1R98Rg729aq4w5spxd_fG64-_mvUJ8sicqOZM9eWjcJK_NBoXMFvHEsmnQhFcCaGpct7la_AJ7S20bbzE70fRshAzvjw8jtFZ6xUEQ=@protonmail.com' \
--to=help-gnu-emacs@gnu.org \
--cc=heimeborgia@protonmail.com \
--cc=stephen.berman@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).