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

Next Comment >Help | Reply To Topic
Author Comment/Response
Mat
09/07/12 4:55pm

Hi all, I have been having some success with the "For" function, however I cannot get it to work with the following example:

For example, I have the list:

b = {1, 2, 3, 4, 5};

For[v = 0, b[[v]] == 3, v++, Print[v]]

The aim of this code is it to print v as 3, because the 3rd number on the list is equal to 3.

This is a simplified version of my problem, but it arises when I use the "b[[v]]==n" as the test for the For loop.

Thanks,

Mat.

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
Next Comment >Help | Reply To Topic