From: Heime <heimeborgia@protonmail.com>
To: Karan Ahlawat <ahlawatkaran12@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: apply function
Date: Mon, 07 Aug 2023 06:42:41 +0000 [thread overview]
Message-ID: <PkbDIyieeHpJmLBzfUAqCjLKra9jNpfcqLszhr0hL8o6ksYPNR4Daw0rvjdC2K_D4WhyioZIkyRsQeg8poIQTbowYX5iQtxHs2HmEqH712A=@protonmail.com> (raw)
In-Reply-To: <7bea436f-42ab-4fa4-9b28-e5fe34776691@gmail.com>
Sent with Proton Mail secure email.
------- Original Message -------
On Monday, August 7th, 2023 at 6:12 PM, Karan Ahlawat <ahlawatkaran12@gmail.com> wrote:
> On 07/08/23 11:15, Heime wrote:
>
> > I have seem code that calls a function in the following way
> >
> > (apply 'nemboss-estring (pp-to-string object) bfname))
> >
> > than the usual
> >
> > (emboss-estring (pp-to-string object) bfname)
> >
> > What might be the reasons for doing so ?
>
>
> The most common use case I've seen for this is that apply can take in a
> list as the arguments to the function, where a list would not work, and
> then spread the elements of the list as individual arguments. So
>
> (+ (list 1 2 3))
>
> doesn't work, but doing
>
> (apply #'+ (list 1 2 3)) ; outputs 6
>
> does work, since it essentially reduces it to (+ 1 2 3)
I want to print the output from a macro by passing its output to a function.
Would use of apply be more appropriate ?
(show-mcode '(thismacro (* 3 5) (* 5 7)))
Or should I use something else ? Should the expansion of a macro be turned
to a list before passing it to a function ?
next prev parent reply other threads:[~2023-08-07 6:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 5:45 apply function Heime
2023-08-07 6:12 ` Karan Ahlawat
2023-08-07 6:42 ` Heime [this message]
2023-08-07 18:44 ` Emanuel Berg
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='PkbDIyieeHpJmLBzfUAqCjLKra9jNpfcqLszhr0hL8o6ksYPNR4Daw0rvjdC2K_D4WhyioZIkyRsQeg8poIQTbowYX5iQtxHs2HmEqH712A=@protonmail.com' \
--to=heimeborgia@protonmail.com \
--cc=ahlawatkaran12@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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).