1
|
1990 Views
|
3 Replies
|
4 Total Likes
View groups...
Share
GROUPS:

# How to get disjunction elements into a list?

Posted 10 years ago
 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 10 years ago
 Hope this helps: In:= Reduce[x^2 == 1, x] Out= x == -1 || x == 1 In:= {ToRules[%]} Out= {{x -> -1}, {x -> 1}} In:= x /. % Out= {-1, 1} In:= Solve[x^2 == 1, x] Out= {{x -> -1}, {x -> 1}} In:= x /. % Out= {-1, 1} 
Posted 10 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[]=List; f Hope that works for you!
Posted 10 years ago
 Great - just what I was looking for. Thanks a lot!