4
$\begingroup$

I want to produce {Foo[a,b, c], Goo[a, b, c], Hoo[a, b, c]}. However my attempt below

Thread[Apply[{Foo, Goo, Hoo}, HoldComplete@Sequence[a, b, c]]]

produces {Foo, Goo, Hoo}[a, b, c].

Could you fix it?

$\endgroup$
3
  • $\begingroup$ Construct[#, Sequence[a,b,c]] & /@ {Foo, Goo, Hoo} ... or if you want to keep the hold and release: ReleaseHold[Construct[#, HoldComplete@Sequence[x, y, z]] & /@ {Foo, Goo, Hoo}] $\endgroup$ – flinty Jun 11 '20 at 0:45
  • $\begingroup$ Let me know if my solution would work for you, or how I might improve it :D $\endgroup$ – CA Trevillian Jun 11 '20 at 0:55
  • $\begingroup$ @flinty: Thank you. $\endgroup$ – Money Sets You Free Jun 11 '20 at 3:00
8
$\begingroup$

Consider Through:

Through[{Foo, Goo, Hoo} @@ {a, b, c}]
{Foo[a, b, c], Goo[a, b, c], Hoo[a, b, c]}

Alternatively, use it as:

Through @ {Foo, Goo, Hoo}[a, b, c]
{Foo[a, b, c], Goo[a, b, c], Hoo[a, b, c]}

Or make it into a function:

boohoo = Through[# @@ #2] &;

{Foo, Goo, Hoo} ~ boohoo ~ {a, b, c}
 {Foo[a, b, c], Goo[a, b, c], Hoo[a, b, c]}
$\endgroup$
5
$\begingroup$
func={Foo,Goo,Hoo};
arg={a,b,c};

#@@arg&/@func
{Foo[a,b,c],Goo[a,b,c],Hoo[a,b,c]}

Let me know if you need an explanation. I figure a list of both functions and arguments would be the simplest method. Then I just made sure the Map over the functions would cause them to Apply to the arguments.

$\endgroup$
1
  • 1
    $\begingroup$ @MoneyOrientedProgrammer glad to hear it! Looks like kglr beat me again though haha D; $\endgroup$ – CA Trevillian Jun 11 '20 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.