Re: Converting an expression to a list of terms?

*To*: mathgroup at smc.vnet.net*Subject*: [mg71482] Re: Converting an expression to a list of terms?*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Mon, 20 Nov 2006 06:17:16 -0500 (EST)*Organization*: The Open University, Milton Keynes, UK*References*: <ejrmpc$96l$1@smc.vnet.net>

AES wrote: > How to convert an expression consisting of a sum of terms in an Output > cell: > > A + B - C + . . . > > (where A, B, C are themselves product expressions) to a list > > {A, B, -C, . . . } > > in some easier fashion than doing it by hand using Find and Replace? > Do you mean applying the head List to the output expression? In[1]:= A + B - C Out[1]= A + B - C In[2]:= Head[%] Out[2]= Plus In[3]:= List @@ %% Out[3]= {A, B, -C} In[4]:= Head[%] Out[4]= List In[5]:= (x - 1)*(x - 2) + (x + 1)*(x + 3) - (x*y + 1)*x^2 Out[5]= 2 (-2 + x) (-1 + x) + (1 + x) (3 + x) - x (1 + x y) In[6]:= Head[%] Out[6]= Plus In[7]:= List @@ %% Out[7]= 2 {(-2 + x) (-1 + x), (1 + x) (3 + x), -x (1 + x y)} In[8]:= Head[%] Out[8]= List Regards, Jean-Marc