# What's the difference between @ and /@? [closed]

The @ and /@ functions do the same thing:

Factorial @ List[1, 2, 3, 4, 5, 6]
{1, 2, 6, 24, 120, 720}

Factorial /@ List[1, 2, 3, 4, 5, 6]
{1, 2, 6, 24, 120, 720}


What is the / for? I've looked all over and can't find any explanation for it.

Edit:

Using f gives the same result:

f[x_] := x + 1

f @ List[1, 2, 3, 4, 5, 6]
{2, 3, 4, 5, 6, 7}

f /@ List[1, 2, 3, 4, 5, 6]
{2, 3, 4, 5, 6, 7}

• The /@ is called Map, it happens to do the same thing as @ in this case because Factorial automatically maps over lists. Try the same thing with f instead of Factorial and you’ll see a difference. Oct 19 at 2:36
• Attributes[Factorial] ,and see Listable . Oct 19 at 2:38
• Oct 19 at 2:41
• Tanner - Sqrt does the same thing. Is f limited to certain types of functions? Oct 19 at 2:55
• Michael E2 - that doesn't help in this case because the explanation about Listable is missing. Oct 19 at 3:17

The difference is that for an arbitrary function f,

• f @ {a,b,c,...} yields f[{a,b,c,...}];
• f /@ {a,b,c,...} yields {f[a], f[b], f[c], ...}.

The two input forms are equivalent for Factorial because it's what's called a Listable function. For a listable function f, the input f[{a,b,c,...}] automatically evaluates to {f[a], f[b], f[c], ...}. So f @ {a,b,c,...}, in the end, gets you the same thing as f /@ {a,b,c,...}.

To see the difference, look at (for example) the function Max instead. When Max is provided with one or more numbers as input, it returns the largest of those numbers. When it is provided with one or more lists, it returns the largest value in any of the lists. So:

• Max @ {1,2,3,4,5,6} is equivalent to Max[{1,2,3,4,5,6}]. Since the argument is a list, Mathematica returns the largest value in the list, 6.
• Max /@ {1,2,3,4,5,6} is equivalent to {Max[1], Max[2], ...}. In each instance, Max is provided with a single number, and so returns that number. So the output is {1,2,3,4,5,6}.
• That's the best explanation I've found anywhere, and I've looked. The key is to know that you have to look at the docs for Listable functions, and newcomers to Mathematica won't know that. Unfortunately book authors don't help in that regard. Oct 19 at 3:12
• Read Leonid shifrin's book. It's free and is a fantastic resource. mathprogramming-intro.org
– Lou
Oct 19 at 5:10