MathGroup Archive 1997

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

Search the Archive

Which, If and "neither True nor False"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9652] Which, If and "neither True nor False"
  • From: "Paul E Howland" <PEHOWLAND at dra.hmg.gb>
  • Date: Mon, 17 Nov 1997 19:50:13 -0500
  • Organization: Defence Research Agency
  • Sender: owner-wri-mathgroup at wolfram.com

I've just stumbled across a bug in some old code of mine, in which I had
a statement of the form:

Which[
        a<b, DoSomething[],
        a>c, DoSomethingElse[],
        True, DoThis[]
        ]

which I assumed would call DoThis[] if neither a<b nor a>c were True.
However, what I didn't realise is that if a is undefined, then the
first two conditions are neither True nor False, and Mathematica
returns the whole Which statement unevaluated!

The If statement has an optional fourth argument which is executed if
the test returns neither True nor False.  Is it possible to do the same
in a Which statement?  If not, why not?!

Paul

Paul E Howland PhD MEng CEng MIEE        Room BY209 Senior Scientist    
DERA (Malvern) Land Systems Sector                      St Andrews Road
Defence Evaluation & Research Agency     Malvern tel.
+44-(0)1684-895767                  Worcestershire fax.
+44-(0)1684-896315                  UK Email PEHowland at dera.gov.uk
Web Site http://www.dera.gov.uk
Official Disclaimer:
The views expressed above are entirely those of the writer and do not
represent the views, policy or understanding of any other person or
official body.




  • Prev by Date: Need help to a beginner.
  • Next by Date: Re: the method of Graphics Display by MathLink
  • Previous by thread: Re: Need help to a beginner.
  • Next by thread: Re: Which, If and "neither True nor False"