Something like the following might be the easiest solution:<br><br>foreach i in [0:20] {<br>  float j = i * 0.5;<br>}<br><br>I think most languages avoid encouraging use of floats as loop variables since its fairly easy to run into surprising behaviour with floating point precision, depending on the way things are implemented. <br>
<br>- Tim<br><br><br><br><div class="gmail_quote">On Tue, Jul 17, 2012 at 11:30 AM, David Kelly <span dir="ltr"><<a href="mailto:davidk@ci.uchicago.edu" target="_blank">davidk@ci.uchicago.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
Is it possible to use foreach with floating point numbers? Right now I can do something like this using ints:<br>
<br>
foreach i in [0:10] {<br>
   tracef("i is %i\n", i);<br>
}<br>
<br>
Is it possible to do something similar with floats using some delta value? For example, for every value between 0.0 and 10.0 in increments of 0.5?<br>
<br>
David<br>
_______________________________________________<br>
Swift-devel mailing list<br>
<a href="mailto:Swift-devel@ci.uchicago.edu">Swift-devel@ci.uchicago.edu</a><br>
<a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel</a><br>
</blockquote></div><br>