MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: using answer form reduce


akil schrieb:
> After using reduce I get the following two types of answers:
> 
> answer == Real1 || answer == Real2
> or
> answer == Real3
> , the type can change from one formula to another.
> 
> I need the Reals, and put them all in a list. The problem is getting all the 
> reals, without knowing which type I deal with, it should be able to be done 
> fast.
> 
> I tried making a list of the returned adres, and then using
> Cases[list, _Real, Infinity] and using Select[list,NumericQ] but both do not 
> give me the answer I require.
> 
> How can I get the answer I require e.g. something like {Real1,Real2,Real3}
> 
> 
> 
Try pattern matching:


type1= answer == Real1 || answer == Real2;
type2= answer == Real3;
getReal=Cases[{#}, answer == y_ :> y, Infinity]&;

getReal[type1]
--> {Real1,Real2}

getReal[type2]
--> {Real3}

getReal[type2 || type1]
--> {Real3,Real1,Real2}


HTH,
Peter


  • Prev by Date: Re: MemberQ
  • Next by Date: Re: using answer form reduce
  • Previous by thread: Re: using answer form reduce
  • Next by thread: Re: using answer form reduce