Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How to extract cases from a Piecewise expression

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)

I'll be happy to include your solutions/contributions in my book.

POSTED BY: Raspi Rascal
5 Replies

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!

POSTED BY: Raspi Rascal

Hi Raspi, interesting things you are doing! Regarding your question - maybe like so:

Sort@Cases[expr, Equal[_, val_] :> val, Infinity]
POSTED BY: Henrik Schachner
POSTED BY: Raspi Rascal

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

POSTED BY: Henrik Schachner
Posted 4 years ago

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} *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard