# How to get disjunction elements into a list?

Posted 9 years ago
1952 Views
|
3 Replies
|
4 Total Likes
|
 Some Mathematica results are returned as disjunctions in the form a || b || c , and the internal form is Or[a,b,c].How do I convert this expression to a list { a, b, c }, for any number of elements in the original disjunction?I'm a Mathematica beginner, and I can see several ways to do it 'manually', but I've learned enough about Mathematica to know that there is always a simple, clean way to do simple things like this.Thanks in advance for any help.
3 Replies
Sort By:
Posted 9 years ago
 Hope this helps: In[1]:= Reduce[x^2 == 1, x] Out[1]= x == -1 || x == 1 In[2]:= {ToRules[%]} Out[2]= {{x -> -1}, {x -> 1}} In[3]:= x /. % Out[3]= {-1, 1} In[4]:= Solve[x^2 == 1, x] Out[4]= {{x -> -1}, {x -> 1}} In[5]:= x /. % Out[5]= {-1, 1} 
Posted 9 years ago
 Simply change the Head of the expression (Or) to List, which can be done in many ways: f=Or[a,b,c] List@@f Apply[List,f] f/.Or->List f[[0]]=List; f Hope that works for you!
Posted 9 years ago
 Great - just what I was looking for. Thanks a lot!