Re: Beginner--Programming Problem with "if"

• To: mathgroup at smc.vnet.net
• Subject: [mg65810] Re: [mg65718] Beginner--Programming Problem with "if"
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Mon, 17 Apr 2006 02:29:06 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Works for me.

\$Version

5.2 for Mac OS X (June 20, 2005)

i=1;If[i==1,x=3;x=x+2;x=x+2,x=2;x=x+2;x=x+2]

7

i=2;If[i==1,x=3;x=x+2;x=x+2,x=2;x=x+2;x=x+2]

6

Bob Hanlon

>
> From: LLCOOLT at gmx.at
To: mathgroup at smc.vnet.net
> Subject: [mg65810] [mg65718] Beginner--Programming Problem with "if"
>
> Hello
>
> I write my programms like this
>
> For[i=1,1>5,i++,
>   Code line 1;
>   Code line 2;
>   Code line 3
> ];
>
> This works until I use If
>
> is there any possibility to combine the code?
>
> this doesn't work:
> If[i==1,(
>   True line 1;
>   True line 2;
>   True line 3
>  ),(
>   Else line 1;
>   Else line 2;
>   Else line 3
> )];
>
>
> Magnetom
>
> Link to the forum page for this post:
> http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?
pageName=Special:Forum_ViewTopic&pid=9611#p9611
> Posted through http://www.mathematica-users.org [[postId=9611]]
>
>
>

```

• Prev by Date: Re: How do I combine Solve and Maximize?
• Next by Date: Re: Plot3D: plot does not display when PlotPoints different from 25. Mathematica 5.2
• Previous by thread: Re: Beginner--Programming Problem with "if"
• Next by thread: Where do I put my own add-on packages?