In a post on the Mathematica Community, Anton Antonov uses a syntax that I have never seen. It is the prefix function @ combined with the Times operator *. The combination appears to bind the command prefixed by the @ sign to the following command, such that the two commands are applied together to an expression. The example is:

titanicData = Flatten@*List@@@ExampleData[{"MachineLearning", "Titanic"}, "Data"];

What I see happening here is that the List command is applied at Level 1 of the List, that is to the first Rule:

{"1st", 29., "female"} -> "survived"

and converts it from a Rule to a nested List

{{"1st", 29., "female"}, "survived"}

and then the Flatten command is applied "immediately" to this Level 1 List in order to remove the nesting:

{"1st", 29., "female", "survived"}

And then this "combined command" (bound by the precedence of the Times operator?) is applied to each Level 1 expression in the example data list (as is expected by the @@@ Apply syntax).

So, I have three questions:

  1. Is my summary above intelligible?
  2. How would this be better stated?
  3. Where is this documented?

Unfortunately, there is one further question:

  1. Is this just obvious to everyone and I am having a brain fart?

Thank you in advance for some enlightenment

  • 2
    $\begingroup$ Use the help facility for "Composition" $\endgroup$ – Christopher Lamb Jul 12 '18 at 4:21
  • $\begingroup$ See What the @#%^&*?! do all those funny signs mean? and search for @*. $\endgroup$ – Michael E2 Jul 12 '18 at 4:32
  • $\begingroup$ The summary is correct. Towards the 4-th question: The answer is "yes". ;p $\endgroup$ – Henrik Schumacher Jul 12 '18 at 5:24
  • 1
    $\begingroup$ That notation has been added sometime after MMA 9.0. I didn't know it existed. Upvoted. $\endgroup$ – Hector Jul 12 '18 at 6:17

See Composition (@*).

Since asterisk is also a wildcard character, it is difficult to find in a direct search.

In your example, Flatten @* List is the composition of the functions Flatten and List.

| improve this answer | |
  • $\begingroup$ +1, but I don't think wildcards work for documentation search (also: for Mathematica, @ is also a wildcard character). I am not convinced that the doc centre couldn't be made to yield reasonable results when searching for @*. $\endgroup$ – Szabolcs Jul 12 '18 at 9:50
  • 3
    $\begingroup$ @Szabolcs The documentation centre appears to use the "standard" * wildcard but nothing else. Searching fibon* and fibon yields 103 and 0 results respectively (screenshot). The problem appears to be unique to @*. Note @@ is able to bring up Apply while @* does not yield Composition (screenshot). Also * alone is able to bring up Times, but * a returns an InputForm cell (screenshot)! Does this strange behaviour merit a new question? $\endgroup$ – user40265 Jul 13 '18 at 5:11

Say you want a function snd that emits the piano sound of the note n. Here is how you can define it:


snd@n will work as expected. Without the double use of @* you will get errors in the definition of the function or you will not get the expected output. Without Composition you need a less concise syntax that uses pure functions (# &) or snd[n_]:= etc.

| improve this answer | |

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