Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm interested in the arguments of f in expressions like


By argument I mean what is here a, b and c. I would like to know the arguments and in what order they appear. For example, the order of the arguments in

 f[d]@(2 x f[b])@f[c]@f[q]


 {d, b, c, q}

How can I find this from the above expression? I tried to use Level[], but the Subvalue construction is hindering me.

share|improve this question
What would be an appropriate title for this question? – sjdh Sep 20 '12 at 12:01
up vote 3 down vote accepted

Here is another way:

Cases[f[d]@(2 x f[b])@f[c]@f[q], f[x_] :> x, {-2}, Heads -> True]
share|improve this answer

This works:

expr = f[d]@(2 x f[b])@f[c]@f[q];
Extract[expr, Position[expr, f[_]], First]
   {d, b, c, q}

Note that Extract[] and Position[] are able to handle expressions with any head, not just lists.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.