Re: Conditionals with multiple tests?

• To: mathgroup at smc.vnet.net
• Subject: [mg24117] Re: Conditionals with multiple tests?
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Wed, 28 Jun 2000 02:11:40 -0400 (EDT)
• Organization: Universitaet Leipzig
• References: <8j9dvs\$523@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

yes.

"The Book" *is* clear in this point. Everything is an expression (except
a comment) including a CompoundExpression[]. If CompoundExpression[]
where
not a expression it's name where CompoundTheOnlyNonExpression[].
Chapter 2.1.1 of "The Book" has the huge bold head line
"Everything Is an Expression" is this clear enough ?

BTW, was it so complicated to try it out inside the Mathematica
interpreter,
that you must write a long news group posting ? Where is the
good old pioneer spirit that say "Let's try it out"?

And what is a "legal way to implement" something, get a court decision
for
every character or only for every expression ?
And what is the punishment for illegal implementations ? Working
programs ?

And is

{p1,p2,p3}=Which[test1,{value11,value12,value13},
test2,{value21,value22,value23},
test3,{value31,value32,value33}]

not better to read and more compact with out a
CompoundExpression[] ?

Perplexed

Jens

"A. E. Siegman" wrote:
>
> Let's say I want to assign values to three variables p1, p2, p3 that
> will depend on five different (and nonoverlapping) tests test1 to test 5.
>
> One way to do this is obviously
>
>       p1 = Which[test1, value11, test2, value12, . . . ]
>       p2 = Which[test1, value21, test2, value22, . . . ]
>       p3 = Which[test1, value31, test2, value32, . . . ]
>
> But a more compact and (for me anyway) neater approach is
>
>    Which[test1, p1=value11; p2=value21; p3=value31,
>               test2, p1=value21; p2=value22; p3=value32,
>               test3, . . .
>               test4, . . .
>               test5, . . . ]
>
> Is this form legal?  That is, can one use:
>
>       Which[test1, expr1, test2, expr2, . . .]
>
> where expr1, expr2, . . . may be compound expressions?
>
> (I would say that The Mathematica Book is not at all clear on this
> point, as regards either Which[] or If[].)
>
> If not, is there a legal way to implement the basic objective?

```

• Prev by Date: Re: Wrong Precision with "N" ??
• Next by Date: Re: How to operate on strictly numerical functions ?
• Previous by thread: RE: Conditionals with multiple tests?
• Next by thread: Re: Conditionals with multiple tests?