Wolfram Language Fast Introduction for Programmers
Get Started »

Functionals & Operators

Many built-in functions in the Wolfram Language can use functional or
operator forms.

This gives the element of a list nearest to 6.3:

In[1]:=
X
Out[1]=

This sets up a nearest function, ready to apply to any specific value:

In[2]:=
X
Out[2]=

Applying it to a particular value gives a specific result:

In[3]:=
X
Out[3]=

Java methods do not typically have "operator" forms.

Python functions do not typically have "operator" forms. This feature can be simulated by using the partial function to create a version of the function with some of its arguments already provided.

With no explicit data supplied, this symbolically represents a selection operation:

In[1]:=
X
Out[1]=

Applying it to explicit data gives a result:

In[2]:=
X
Out[2]=
Check Your Understanding

Which of the following gives a symbolic representation of a nearest function?

Nearest[{3, 5, 15, 32}]

Correct.

Nearest[{3, 5, 15, 32}, 12]

Incorrect. This returns a nearest calculation.

After the assignment f = Nearest[{10, 20, 30}], which of these gives the same result as f[12]?

Select[{10, 20, 30}][12]

Incorrect. Select is not the same as Nearest.

Nearest[{10, 20, 30}, 12]

Correct.

12

Incorrect. The 12 is the argument to the functional f. The value returned is 10.

Which one of these is a selection operator?

Select[PrimeQ]

Correct.

Select[{2, 3, 4, 5}, PrimeQ]

Incorrect. This returns {3, 5}.

Select[PrimeQ][{2, 3, 4, 5}]

Incorrect. This returns {3, 5}.