Message Boards Message Boards

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

GROUPS:

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
Answer
5 months ago
In[1]:= List @@ (a + b + c + d)

Out[1]= {a, b, c, d}
POSTED BY: Frank Kampas
Answer
5 months ago

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
Answer
5 months ago

Thanks

POSTED BY: Jesse Sheinwald
Answer
5 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 ...

POSTED BY: Henrik Schachner
Answer
5 months ago

Group Abstract Group Abstract