4
$\begingroup$

What is the name for the function #1[#2]&?

I would call it Apply, so that Apply[Sin,2] is Sin[2], but the real Mathematica's Apply does a different thing.

$\endgroup$
2
  • $\begingroup$ Perhaps Operate? E.g., Operate[Sin,2,0]. $\endgroup$
    – Alan
    Sep 25, 2016 at 3:37
  • $\begingroup$ Nest[Sin,2,1] $\endgroup$
    – george2079
    Sep 25, 2016 at 11:56

2 Answers 2

7
$\begingroup$

This would be Compose:

Compose[Sin, 2]
(* Sin[2] *)

#1[#2] &[Sin, 2]
(* Sin[2] *)
$\endgroup$
2
  • $\begingroup$ You must have been using Mma for a long time! One cannot even get documentation for Compose any more. $\endgroup$
    – Alan
    Sep 25, 2016 at 3:23
  • 1
    $\begingroup$ +1 as Compose is the closest thing we have. In the comments of (11298) there is some discussion about 1) a name for #1[#2]& or, more generally, for #1[##2]&; 2) whether Compose is a good name for that operation; and 3) the obsolescence of Compose. $\endgroup$
    – WReach
    Sep 25, 2016 at 4:53
3
$\begingroup$

Your function is anonymous. You can use it like this.

#1[#2]&[Sin, 30 °]

1/2

You can also give it a name.

apply = #1[#2]&;

then

apply[Sin, 30 °]

1/2

$\endgroup$

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