Wolfram Computation Meets Knowledge

The Wolfram Language:
Fast Introduction for Programmers

Show additional notes for:
All sections 
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]:=1
Nearest[{1, 4, 6, 8, 10, 15}, 6.3]
Out[1]=1

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

In[2]:=2
Nearest[{1, 4, 6, 8, 10, 15}]
Out[2]=2

Applying it to a particular value gives a specific result:

In[3]:=3
%[6.3]
Out[3]=3

Notes for Java programmers:

Java methods do not typically have "operator" forms.

Notes for Python programmers:

The "operator" forms in the Wolfram Language enable the creation of new functions by providing some of the arguments of a built-in function. Similar functionality in Python would require calling the partial function or writing your own custom wrapper function.


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

In[1]:=1
Select[# > 7 &]
Out[1]=1

Applying it to explicit data gives a result:

In[2]:=2
Select[# > 7 &][{1, 4, 6, 8, 10, 15}]
Out[2]=2

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


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


Which one of these is a selection operator?

© 2017 Wolfram. All rights reserved.