Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: If-statement problems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49489] Re: If-statement problems
  • From: BobHanlon at aol.com
  • Date: Thu, 22 Jul 2004 02:44:53 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

{a, b, c, d} = A;


Bob Hanlon

> In a message dated Wed, 21 Jul 2004 11:11:17 +0000 (UTC), <
> aaronfude at yahoo.com> writes: New to Mathematica. I can't figure out how to use the 
> if-statement for pure
> flow control.
> 
> Here's an example:
> 
> A = {5, 6, 7, 8}
> For [n = 1, n <= 4, n++,
>  if [n == 1, a = A[[n]]];
>  if [n == 2, b = A[[n]]];
>  if [n == 3, c = A[[n]]];
>  if [n == 4, d = A[[n]]];
> ]
> 
> I want to assign to a b c and d the 4 values from A. Obviously, that's not
> what happens. How do I accomplish what I need?
> 


  • Prev by Date: numerical solution of an ODE doesn't make sense
  • Next by Date: Simple Module Code
  • Previous by thread: Re: If-statement problems
  • Next by thread: Re: If-statement problems