[Date Index] [Thread Index] [Author Index]
Re: Beginner--Programming Problem with "if"
On 4/16/06 at 1:45 AM, LLCOOLT at gmx.at wrote: >I write my programms like this >For[i=1,1>5,i++, > Code line 1; > Code line 2; > Code line 3 >]; While the above is correct syntax and will work, it is generally has poorer perforamance (slower) than functional programming methods. >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 >)]; You need to use correct Mathematica syntax, i.e., If[i == 1, line 1; line 2; line 3, line 1; line 2; line 3] Note where the ; and , appear. The ; separates lines within a block of lines. The , separates the block which executes when the test is true (first block) from the block that executes when the test is false (second block). -- To reply via email subtract one hundred and four