Re: Matching Or expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg72267] Re: Matching Or expressions
- From: "Richard KAUSCH" <rkausch at free.fr>
- Date: Sun, 17 Dec 2006 06:20:21 -0500 (EST)
- References: <firstname.lastname@example.org>
Hello Johan After the exemple you give ,it seems that the equations you are dealing with are in two variables (?). If so ,solutions should be written in list form instead of x == and y == . That way ,they would not counted twice (you write that x =2 and y = 4 is ONE solution). Was it the real problem? Regards. Richard Johan Grönqvist a écrit : > The context of my problem is explained below. > > I wish to distinguish expressions of the form And[p,q] from those of the > form Or[p,q], but the only thing I find is > MatchQ[myExpr, Or[_]] > and to my surprise I see that MatchQ[And[p,q],Or[_]] is True. Thus I can > not use this to match only the Or-expressions. > > Thanks > > Johan > > The context is as follows: > > I wish to find the number of solutions to a diophantine equation with a > finite number of solutions. > > I do the following > sols = Reduce[eqns, vars, Integers] > and this gives me an expression that normally looks like Or[_,_,_] if > there are several solutions, or something else if there are not. > > Now I wish to find the number of solutions using > Which[MatchQ[sols, Or[_]], Length[sols], DoOtherStuff] > > The problem is that the MatchQ[ expr, Or[_] ] also matches e.g. (x==2 && > y==4), which is only one solution.