Since lists are just a particular kind of expression, it will come as no surprise that you can refer to parts of any expression much as you refer to parts of a list.
You can refer to parts of an expression such as f[g[a], g[b]]
just as you refer to parts of nested lists.
You should realize that the assignment of indices to parts of expressions is done on the basis of the internal Mathematica
forms of the expression, as shown by FullForm
. These forms do not always correspond directly with what you see printed out. This is particularly true for algebraic expressions, where Mathematica
uses a standard internal form, but prints the expressions in special ways.
You can manipulate parts of expressions just as you manipulate parts of lists.
"Manipulating Elements of Lists"
discusses how you can use lists of indices to pick out several elements of a list at a time. You can use the same procedure to pick out several parts in an expression at a time.
Any part in an expression can be viewed as being an argument of some function. When you pick out several parts by giving a list of indices, the parts are combined using the same function as in the expression.