Cases[ expr , F[__] , Infinity]
{F[0, 0], F[0, 1], F[2, 0]}
Note the order you keyed them in is lost because mathematica puts the terms in canonical order as soon as you evaluate the expr=..
assignment.
Frage
I have an expression like this:
expr=F[0, 1] + 2 F[0, 0] - 17*F[2, 0]
and i want to transform it to a list consisting of all function calls with its arguments:
MyList={F[0, 1], F[0, 0], F[2, 0]}
Does anyone know a clever way to do this in Mathematica?
My currently best solution is using ToString and do string-manipulations, but it is defintivly very slow and ugly.
Thanks alot! Andreas
Lösung
Cases[ expr , F[__] , Infinity]
{F[0, 0], F[0, 1], F[2, 0]}
Note the order you keyed them in is lost because mathematica puts the terms in canonical order as soon as you evaluate the expr=..
assignment.