This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /

  • MapIndexed[ f , expr ] applies f to the elements of expr, giving the part specification of each element as a second argument to f.
  • MapIndexed[ f , expr , levspec ] applies f to all parts of expr on levels specified by levspec.
  • Example: MapIndexed[f, a, b, c ].
  • Level specifications are described in Section A.3.6.
  • The default value for levelspec in MapIndexed is {1}.
  • Example: MapIndexed[f, a, b , c, d , Infinity].
  • See the Mathematica book: Section 2.2.4.
  • See also: MapAt.

    Further Examples

    This applies f to each element in a list, giving the index of the element as a second argument to f.



    This applies f to both levels in a matrix.