Message Boards Message Boards


[✓] Turn the terms of an expression into a list?

Posted 6 months ago
4 Replies
0 Total Likes

I want to turn expression a+b+c+d into list {a,b,c,d}. I always thought there was a command to do this. Any thoughts on a simple way to do this?

4 Replies
In[1]:= List @@ (a + b + c + d)

Out[1]= {a, b, c, d}

Frank's solution replaces any head (Plus in this case) with the head List

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

Mine explicitly replaces Plus with List, same outcome for this input.

Posted 6 months ago


Just as the documentation states:

FullForm is your friend!

a + b + c + d // FullForm
(* Out:  Plus[a,b,c,d]  *)

This already gives the basic idea on what to do ...

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract