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

  • Level[ expr , levelspec ] gives a list of all subexpressions of expr on levels specified by levelspec.
  • Level[ expr , levelspec , f ] applies f to the list of subexpressions.
  • Level uses the standard level specification described in Section A.3.6.
  • Level[ expr , -1 ] gives a list of all "atomic" objects in expr.
  • Level traverses expressions in depth-first order, so that the subexpressions in the final list are ordered lexicographically by their indices.
  • See the Mathematica book: Section 2.1.7.
  • See also: Apply, Map, Scan.

    Further Examples

    Here are the subexpressions of the polynomial at the first four levels.

    In[1]:=

    Out[1]=

    Here are the subexpressions of the polynomial at the first four levels.

    In[2]:=

    Out[2]=

    Here are the subexpressions of the polynomial at the first four levels.

    In[3]:=

    Out[3]=

    Here are the subexpressions of the polynomial at the first four levels.

    In[4]:=

    Out[4]=