Re: How to tell Mathematica to stop conditional testing in an If
- To: mathgroup at smc.vnet.net
- Subject: [mg69542] Re: How to tell Mathematica to stop conditional testing in an If
- From: dh <dh at metrohm.ch>
- Date: Fri, 15 Sep 2006 06:45:02 -0400 (EDT)
statment if one condition is niether True or False? McCarthy evaluation rules? 'and then' test? References: <eebfu3$5dt$1 at smc.vnet.net> Organization: hispeed.ch X-Wrienvfrom: <mathgroup-adm at smc.vnet.net> X-Wrienvto: <ldegler at wolfram.com> X-Wrienvto: <onkars at wolfram.com> X-Wrienvto: <brucem at wolfram.com> X-Wrienvto: <overmann at wolfram.com> X-Wrienvto: <emre at wolfram.com> X-Wrienvto: <mauricios at wolfram.com> X-Wrienvto: <xwen at wolfram.com> X-Wrienvto: <chrisw at wolfram.com> X-Wrienvto: <darreng at wolfram.com> X-Wrienvto: <ericb at wolfram.com> X-Wrienvto: <brenton at wolfram.com> X-Wrienvto: <l-mathgroup at wolfram.com> X-Wrienvto: <layland at wolfram.com> X-Wrienvto: <fredm at wolfram.com> X-Wrienvto: <carlson at wolfram.com> X-Wrienvto: <dkapadia at wolfram.com> X-Wrienvto: <jasonh at wolfram.com> X-Wrienvto: <pratikd at wolfram.com> X-Wrienvto: <marykab at wolfram.com> X-Wrienvto: <stevec at wolfram.com> X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.4.0.264935, Antispam-Data: 2006.9.15.51443 Hi Nasser, SameQ(or "===" will return "False" if the condition is false or undecideable. Daniel Nasser Abbasi wrote: > I can better describe this with simple example: > > ------------- code ------------ > > Remove["Global`*"]; > xc = Table[i, {i, 1, 3}] > x = 5; > If[x == b && xc[[10]] == 4, Print["True"], Print["False"], Print["Can't > decide"]] > > ----- end code ------------- > In the above, 'x==b' is neither True nor False, since 'b' has no numerical > value. > > But what I want is when this happens, for Mathematica to NOT continue with > the testing if xc[[10]]==4 is True (because even if it is True, it will > not change the outcome, which is can't decide. > > I am looking for something like 'and then' which says to test the next > condition only if the one just tested was true. > > The interesting thing is that if 'b' had a value, say 7, which makes the > first test (the x==b) to be False, then Mathematica does the right thing, > and will not try to check the xc[[10]]==4 condition. I need it to do the > same thing when also the result of the check is 'undecided', not just > 'False' or 'True'. > > Is there a way to do this? Notice in the example above, I get the error > that xc[[10]] is out of bound, but still get the can't decide message. > > It is clear to me that the way Mathematica does it now is not the right way. > I do not see why it tries to check for xc[[10]]==4 when it will not make a > difference to the final result. > > any thoughts? > > thanks, > Nasser > > >