Maxima Function
partition (expr, x)
Returns a list of two expressions. They are (1) the factors of expr (if it is a product), the terms of expr (if it is a sum), or the list (if it is a list) which don't contain var and, (2) the factors, terms, or list which do.
(%i1) partition (2*a*x*f(x), x); (%o1) [2 a, x f(x)] (%i2) partition (a+b, x); (%o2) [b + a, 0] (%i3) partition ([a, b, f(a), c], a); (%o3) [[b, c], [a, f(a)]]