The Wolfram Language includes many powerful operations for working with lists. It is often desirable to map a function onto each individual element in a list. While listable functions do this by default, you can use Map to do this with non-listable functions.
You can map a function over every element of the list using Map; this example uses an undefined function :
You can use as a shorthand for Map (this is the same command as in the previous example):
Most mathematical functions have the Listable property, meaning they automatically map over lists:
Now use Map to calculate the eigenvalues of each of the matrices in the list:
Map does not just operate on lists. It can be used for any expression:
Apply is another functional programming operation. It replaces the head of an expression.
Apply has for a shorthand notation (this is the same command as the previous example):
Apply is useful when you want to turn the elements in a list into function arguments.
Mod finds the remainder when dividing the first number of an ordered pair by the second:
To apply Mod to all of the pairs, you need to work at level 1 of the list (specified by the ):
This is another way to do the same thing using a pure function with Function:
This uses the short form of Function: