help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: apply function


From: Heime
Subject: Re: apply function
Date: Mon, 07 Aug 2023 06:42:41 +0000





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 ?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]