MathGroup Archive 2003

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

Search the Archive

Re: Re: Boolean type-checking

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41863] Re: [mg41811] Re: Boolean type-checking
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sat, 7 Jun 2003 00:08:54 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <bbnal0$2d4$1@smc.vnet.net> <200306061350.JAA13014@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

I want one behavior when the variable takes value True; another when 
that variable takes value False; and an unevaluated expression returned 
when the variable takes any other value (as by improper usage of the 
function).

I do NOT want one behavior when the variable takes value True and an 
alternative in every other case!

And I still raise the question as to why Mathematica does not have a 
built-in object for {True, False}.

Jens-Peer Kuska wrote:
> Hi,
> 
> hmm, and TrueQ[] does what ?
> 
> TrueQ[expr] yields True if expr is True, and yields False otherwise.
> 
> why do you want to to know if expr is False  if you can check
> that it is true ?
> 
> Regards
>   jens
> 
> Murray Eisenberg wrote:
> 
>>When type checking the argument to a function, it's often easy to use a
>>built-in object in a pattern, e.g.:
>>
>>   f[n_Integer] := n + 1
>>
>>   g[x_?Positive] := Sqrt[x]
>>
>>But what about type-checking that an argument is Boolean, i.e., True or
>>False?  Of course it's easy enough to define a function to do this:
>>
>>   tfQ[sym_] := MemberQ[{True, False}, sym]
>>   (* or:  tfQ[sym_] := Element[sym, Booleans] *)
>>
>>   h[y_, flag_?tfQ] := ....
>>
>>But is there no NAMED, single built-in object that does what the
>>above-defined tfQ does?
>>
>>If I am correct that there is not, this may result from what seems to be
>>a fundamental language design decision, namely, that True and False are
>>just symbols -- they do have head Symbol -- rather than being of a
>>special type having, say head Boolean.  Why was that design decision made?
>>
>>--
>>Reply to "REPLY TO" address and NOT to the "FROM" address!!
>>Otherwise I will never see your reply!!!!!!!!!!!!!!!!!!!!!!
>>
>>Murray Eisenberg                     murray at math.umass.edu
>>Mathematics & Statistics Dept.
>>Lederle Graduate Research Tower      phone 413 549-1020 (H)
>>University of Massachusetts                413 545-2859 (W)
>>710 North Pleasant Street            fax   413 545-1801
>>Amherst, MA 01003-9305
> 
> 
> 

-- 
Reply to "REPLY TO" address and NOT to the "FROM" address!!
Otherwise I will never see your reply!!!!!!!!!!!!!!!!!!!!!!

Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Re: Re: A bug?......In[1]:= Sum[Cos[x], {x, 0, Infinity, Pi}]......Out[1]= 1/2
  • Next by Date: Front end tokens
  • Previous by thread: Re: Boolean type-checking
  • Next by thread: Re: Re: Re: Boolean type-checking