Message Boards Message Boards

0
|
5334 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

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

Posted 6 years ago

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?

POSTED BY: Jesse Sheinwald
4 Replies

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 ...

POSTED BY: Henrik Schachner

Thanks

POSTED BY: Jesse Sheinwald

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 BY: Sander Huisman
In[1]:= List @@ (a + b + c + d)

Out[1]= {a, b, c, d}
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract