From: Murray Eisenberg on
Very easy -- and you'll doubtless get lots of replies to this.

Apply[List, a + b + c]
{a, b, c}

(* same thing using special input form: *)
List @@ (a + b + c)
{a, b, c}

List @@ (a*b*c)
{a, b, c}

If, however, your expression involves several different operations,
things get more complicated. You could then, e.g., use Apply at various
levels.

On 6/26/2010 3:09 AM, uno wrote:
> Hi,
>
> I have an expression that is a sum of terms, like
> a+b+c
> and I want to convert it to a list, with as many elements as the
> number of terms in the sum of terms, and with each element being each
> of the terms, like
> {a,b,c}
>
> Also, the same to go from a product of terms like
> a*b*c
> to a list like
> {a,b,c}
>
> Is there any way, in Mathematica, to do this?
> I've been looking for an answer in the Help, and in the web, with no
> help.
>
> I ask this because "a*b+c+e*f*g" needs to be evaluated by an external
> (.NET) program, which is not able to parse expressions. I have to
> "break" everything inside Mathematica, before sending information to
> that external program, which will evaluate that expression many times,
> for different values of {a,b,c,d,e,f,g}.
>
> Thank you.
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

From: Richard Fateman on

If you want to send a Mathematica expression that is already parsed, use
FullForm.
Even {a,b,c} needs to have some parsing, and a FullForm expression
needs very little more.


While List@@(a+b I) gives {a, I*b},

note that List@@(3+ 4 I) does not give {3, I*4}.

This is supposed to be a feature.

From: Richard Fateman on

If you want to send a Mathematica expression that is already parsed, use
FullForm.
Even {a,b,c} needs to have some parsing, and a FullForm expression
needs very little more.


While List@@(a+b I) gives {a, I*b},

note that List@@(3+ 4 I) does not give {3, I*4}.

This is supposed to be a feature.

From: Nasser M. Abbasi on
On 6/29/2010 3:57 AM, Richard Fateman wrote:
> If you want to send a Mathematica expression that is already parsed, use
> FullForm.
> Even {a,b,c} needs to have some parsing, and a FullForm expression
> needs very little more.
>
>
> While List@@(a+b I) gives {a, I*b},
>
> note that List@@(3+ 4 I) does not give {3, I*4}.
>
> This is supposed to be a feature.
>

it seems in the second case, this happens becuase the expression was
evaluated first? By holding evaluation, one can get the same result as
in the first case:

List @@ (a + b*I)
{a, I*b}

List @@ (3 + 4*I)
3 + 4*I

ReleaseHold@(List @@ (3 + Hold@4*I))
{3,4 I}


--Nasser

From: Bill Rowe on
On 7/1/10 at 8:27 AM, nma(a)12000.org (Nasser M. Abbasi) wrote:

>it seems in the second case, this happens becuase the
>expression was evaluated first? By holding evaluation, one can
>get the same result as in the first case:

>List @@ (a + b*I)
>{a, I*b}

>List @@ (3 + 4*I)
>3 + 4*I

>ReleaseHold@(List @@ (3 + Hold@4*I))
>{3,4 I}

Not quite the right explanation. The key is 3 + 4 I isn't an
expression in the same sense as 3.4 isn't an expression. That is
it has no parts. It makes no more sense to have List@@(3+4 I)
yield {3, 4 I} then it does to have List@@{3.4} yield either
{3.4} or {3, 4}.

By adding Hold, you create a new expression which has parts. Now
you can use Apply to change this to a list and rid yourself of
the Hold part using ReleaseHold.