MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to separate a sum into terms

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92048] Re: How to separate a sum into terms
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 18 Sep 2008 06:15:26 -0400 (EDT)

On 9/17/08 at 4:29 AM, slava.rychkov at gmail.com (Slava Rychkov) wrote:


>I want to separate a Mathematica expression written as a sum into
>separate terms E.g. for

>a+b-c+f[1]-g[a]/g[b]

>I want to get a list

>{a,b,-c,f[1],-g[a]/g[b]}

>Is there a simple way to do this?

Yes, simply change the head of the sum to List using Apply. That is

In[1]:= expr = a + b - c + f[1] - g[a]/g[b];

In[2]:= List @@ expr

Out[2]= {a,b,-c,f(1),-(g(a)/g(b))}

In[3]:= Apply[List, expr]

Out[3]= {a,b,-c,f(1),-(g(a)/g(b))}


  • Prev by Date: Re: How to separate a sum into terms
  • Next by Date: Re: Using Mathematica with GSL
  • Previous by thread: Re: How to separate a sum into terms
  • Next by thread: Re: How to separate a sum into terms