# Maple like collect command in Mathematica

In Maple I often simplify expressions for functions of same argument using the collect command:

> collect(a*f(x)+f(y)+x*f(x), f, factor)
(a+x)*f(x)+f(y)


where the extra option factor will factor the coefficients.

In contrast Mathematica:

> Collect[a*f[x] + f[y] + x*f[x], f]
a f[x] + x f[x] + f[y]


Is there some command in Mathematica which achieves the same?

-
You need to use a pattern in Collect which will match the terms you are trying to collect. In this case we want to collect terms like f[x] and f[y] so a suitable pattern is _f which matches any expression with head f:
Collect[a*f[x] + f[y] + x*f[x], _f]

@highsciguy, Collect takes a third argument which is a function to be applied to each coefficient. –  Simon Woods Dec 18 '13 at 22:20