Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /
Map

  • Map[ f , expr ] or f /@ expr applies f to each element on the first level in expr.
  • Map[ f , expr , levelspec ] applies f to parts of expr specified by levelspec.
  • Examples: Map[f, a, b, c ]; Map[f, a + b + c].
  • Level specifications are described in Section A.3.6.
  • The default value for levelspec in Map is {1}.
  • Examples: Map[f, a,b , c,d ]; Map[f, a,b , c,d , 2]; Map[f, a,b , c,d , -1].
  • See the Mathematica book: Section 2.2.4.
  • See also: Apply, Scan, Level, Operate, MapThread.

    Further Examples

    This reverses each of the pairs in the list.

    In[1]:=

    Out[1]=

    This maps the function f only at the second level.

    In[2]:=

    Out[2]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.