MathGroup Archive 2003

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

Search the Archive

Re: What's legit here?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39987] Re: What's legit here?
  • From: Bill Rowe <listuser at earthlink.net>
  • Date: Thu, 13 Mar 2003 03:06:24 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 3/12/03 at 2:31 AM, stevebg at adelphia.net (Steve Gray) wrote:

>In the following function, most of which you can ignore, there is an
>If [ enalist ... etc. where several statements to be executed if the
>If succeeds are grouped with ( ) . This works but I thought the right
>way to group several statements together was with { }.

No, {} is always used to create a list. So,

If[test, {expr1, expr2, expr3 ...}]

will return a list containing the values of the expressions when test is true

The simplest way to have a block of expressions execute if true is as follows:

If[test,
   expr1; expr2; expr3; , (* block executed if test = true *)
   fexpr1; fexpr2; expr3 (* block executed if test = false *)
   ]
   
That is the separator between statements in a block to be executed is a semicolon. The separator between the true and false block is a comma. If you are used to C progamming this swaps the roles of the semicolon and comma.


  • Prev by Date: Re: This should evaluate to zero
  • Next by Date: Re: Right-click'd BMP vs. exported BMP
  • Previous by thread: Re: What's legit here?
  • Next by thread: Re: What's legit here?