When you write f[x] it means “apply the function f to x”. An alternative way to write the same thing in the Wolfram Language is f@x.

f@x

f@g@h@x

ColorNegate@EdgeDetect@

There’s a third way to write f[x] in the Wolfram Language: as an “afterthought”, in the form x//f.

x//f

x//f//g//h

//EdgeDetect//ColorNegate

A particularly common use of // is to apply N (for numerical evaluation) “as an afterthought”.

2Pi^3+1//N

In working with the Wolfram Language, a powerful notation that one ends up using all the time is /@, which means “apply to each element”.

f/@{1,2,3}

f[{1,2,3}]

Framed is a function that displays a frame around something.

Framed[x]

Applying Framed to a list just puts a frame around the whole list.

Framed[{x,y,z}]

Framed@{x,y,z}

Framed/@{x,y,z}

The same thing works with any other function. For example, apply the function Hue separately to each number in a list.

Hue/@{0.1,0.2,0.3,0.4}

{Hue[0.1],Hue[0.2],Hue[0.3],Hue[0.4]}

It’s the same story with Range, though now the output is a list of lists.

Range/@{3,2,5,6,7}

{Range[3],Range[2],Range[5],Range[6],Range[7]}

Given a list of lists, /@ is what one needs to do an operation separately to each sublist.

PieChart/@{{1,1,1,1,1,1,1},{1,1,1,4,4,4},{1,2,1,2,1,2}}

You can use exactly the same idea with lots of other functions.

Length/@{{a,a},{a,a,b,c},{a,a,b,b,b,b},{a,a,a},{c,c}}

Length@{{a,a},{a,a,b,c},{a,a,b,b,b,b},{a,a,a},{c,c}}

Reverse/@{{a,b,c},{x,y,z},{1,2,3,4}}

Reverse@{{a,b,c},{x,y,z},{1,2,3,4}}

Reverse[{{a,b,c},{x,y,z},{1,2,3,4}}]

Some calculational functions are listable, which means they automatically apply themselves to elements in a list.

N[{1/3,1/4,1/5,1/6}]

Prime[{10,100,1000,10000}]

A function like Graphics definitely isn’t listable.

Graphics[{Circle[ ],RegularPolygon[7],Style[RegularPolygon[3],Orange]}]

Graphics/@{Circle[ ],RegularPolygon[7],Style[RegularPolygon[3],Orange]}

When you enter f/@{1,2,3}, the Wolfram Language interprets it as Map[f,{1,2,3}]. f/@x is usually read as “map f over x”.

Map[f,{1,2,3}]

Use /@ and Range to reproduce the result of Table[f[n],{n,5}]. »

Use /@ twice to generate Table[f[g[n]],{n,10}]. »

Use // to create a[b[c[d[x]]]]. »

Make a list of letters of the alphabet, with a frame around each one. »

Color negate an image of each planet, giving a list of the results. »

Use /@ to draw separate maps of each country in the G5. »

Binarize each flag in Europe, and make an image collage of the result. »

Find a list of the dominant colors in images of the planets, putting the results for each planet in a column. »

Find the total of the letter numbers given by LetterNumber for the letters in the word “wolfram”. »

Why not always use f@x instead of f[x]?

f@x is a fine equivalent to f[x], but the equivalent of f[1+1] is f@(1+1), and in that case, f[1+1] is shorter and easier to understand.

Why is /@ called Map?

It comes from math. Given a set {1,2,3}, f/@{1,2,3} can be thought of as mapping of this set to another one.

How does one say "//" and "/@"?

Typically “slash slash” and “slash at”.

When do I need to use parentheses with @, // and /@?

It’s determined by the precedence or binding of different operators. @ binds tighter than +, so f@1+1 means f[1]+1 not f@(1+1) or f[1+1]. // binds looser than +, so 1/2+1/3//N means (1/2+1/3)//N. In a notebook you can find how things are grouped by repeatedly clicking on your input, and seeing how the selection expands.

Tech Notes