How do we extract all the cases of Equal expressions from a Piecewise expression output? (here for example: looking for the support of the random variable Y)
Thanks everyone, you guys made my day!
True ... omg that was too funny. I wouldn't have figured that one out. Definitely made it into the book and for further use in there. Next week I'm learning the basics of Bernoulli trials and binomial distribution yay!
True
Hi Raspi, interesting things you are doing! Regarding your question - maybe like so:
Sort@Cases[expr, Equal[_, val_] :> val, Infinity]
Hi Raspi, I always enjoy reading your questions! Here it took me a while to understand why your first attempt fails: Equal[_, _] evaluates to True before anything else is happening ...
Equal[_, _]
To prevent early evaluation
Cases[expr, HoldPattern[Equal[_, _]], Infinity] (* {y == 2, y == 12, y == 3, y == 11, y == 4, y == 10, y == 5, y == 9, y == 6, y == 8, y == 7} *)