Wolfram Computation Meets Knowledge

The Wolfram Language:
Fast Introduction for Programmers

Show additional notes for:
All sections 
Get Started

Functionals & Operators Video Version

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:

Nearest[{1, 4, 6, 8, 10, 15}, 6.3]

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

Nearest[{1, 4, 6, 8, 10, 15}]

Applying it to a particular value gives a specific result:


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:

Select[# > 7 &]

Applying it to explicit data gives a result:

Select[# > 7 &][{1, 4, 6, 8, 10, 15}]

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?

© 2022 Wolfram. All rights reserved.