# Transform a Sum into a List

I want to turn a sum like this

sum =a-b+c+d


Into a List like this:

sumToList[sum]={a,-b,c,d}


How can I achieve this?

-

List @@ sum
(* {a, -b, c, d} *)


From the docs on Apply (@@):

f@@expr replaces the head of expr by f.

So List@@sum replaces Head[sum] (that is, Plus) with List.

-

Try :

a - b + c + d /. Plus -> List


You can have a look at a - b + c + d //FullForm to see why this works.

-
Good one. And maybe sum[[0]] = List; sum –  TomD Oct 22 '12 at 19:32
@TomD that is the one I like to use :) –  Mike Honeychurch Oct 22 '12 at 22:24

Still another route:

Last[CoefficientArrays[#]] Variables[#] &[a - b + c + d]
{a, -b, c, d}

-