Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'For Loop' topicStudent Support Forum > General > "For Loop"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
09/07/12 9:52pm

In[1]:= b={1,2,3,4,5};
For[v=1,v≤Length[b],v++,
If[b[[v]]\[Equal]3,Break[]]
];
Print[v]

From In[1]:= 3

In[4]:= b={1,2,3,4,5};
For[v=1,v≤Length[b],v++,
If[b[[v]]\[Equal]3,Print[v]]
];

From In[4]:= 3

In[6]:= b={1,2,3,4,5};
For[v=1,v≤Length[b]&&b[[v]]≠3,v++,
v
];
Print[v]

From In[6]:= 3

URL: ,

Subject (listing for 'For Loop')
Author Date Posted
For Loop Mat 09/07/12 4:55pm
Re: For Loop Bill Simpson 09/07/12 9:52pm
Re: For Loop Nasser M. Ab... 09/08/12 02:18am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic