[Swift-devel] how to increment int?

Mike Kubal mikekubal at yahoo.com
Tue Dec 18 08:03:30 CST 2007


Thanks Ben,

I tried both approaches, but I get the following
errors:

Could not compile SwiftScript source: line 9:11:
unexpected token: {
with the line:  

iterate i {  

I get a similar error 

Could not compile SwiftScript source: line 12:23:
unexpected token: [

with the line 

foreach job_number in [1000000:10000098]

Thanks,

Mike


--- Ben Clifford <benc at hawaga.org.uk> wrote:

> 
> 
> > In the swift code loop below I need to increment
> the
> > start_job variable by 1, however I get the error
> that
> > start_job is already assigned, how should I do it?
> 
> 
> > while( start_job < 10000998){
> 
> Don't use while - it shouldn't even be in the
> language, in my opinion, 
> given that I've never seen a successful use of it.
> 
> Here are two ways of saying what I think you want:
> 
> THere's an 'iterate' statement that will give you a
> counter for each loop.
> 
> Section 2.6.4 in here: 
>
http://www.ci.uchicago.edu/swift/guides/userguide.php#id2663424
> 
> something like
> 
> iterate i {
>     int job_number = i + 10000000;
>     [...]
> } until(job_number >= 1000098)
> 
> 
> You could also express it as this, which perhaps
> better expresses the 
> parallelism (though I think both the iterate use
> above and the foreach use 
> below will behave about the same).
> 
> foreach job_number in [1000000:10000098] {
>    [....]
> }
> 
> 
> -- 
> 
> 
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
>
http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel
> 
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs



More information about the Swift-devel mailing list