Re: Boolean type-checking
- To: mathgroup at smc.vnet.net
- Subject: [mg41811] Re: Boolean type-checking
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 6 Jun 2003 09:50:41 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bbnal0$2d4$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
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
- Follow-Ups:
- Re: Re: Boolean type-checking
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: Boolean type-checking