Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Return[] does not work inside Do[]' topicStudent Support Forum > General > "Return[] does not work inside Do[]"

Next Comment >Help | Reply To Topic
Author Comment/Response
Dims
04/27/10 05:09am

The following definition does work:

f[x_] := (If[x > 5, Return[a]]; x + 3)

(it's from manula)

The following definition does not:

f[x_] := (Do[If[x > 5, Return[a]], {10}]; x + 3)

(returns x+3 all the time)

The only difference of the last definition is that it executes If 10 time. Return[] stops working in such a case.



URL: ,

Subject (listing for 'Return[] does not work inside Do[]')
Author Date Posted
Return[] does not work inside Do[] Dims 04/27/10 05:09am
Re: Return[] does not work inside Do[] yehuda ben-s... 05/02/10 12:40pm
Re: Return[] does not work inside Do[] Peter Pein 05/07/10 02:28am
Next Comment >Help | Reply To Topic