Wiki

Changes between Version 1 and Version 2 of NumericFor

Show
Ignore:
Timestamp:
07/12/08 21:09:38 (16 years ago)
Author:
Chuck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NumericFor

    v1 v2  
    11= Numeric For = 
    22== Grammar == 
    3 {{{ 
    4  old-numeric-for-statement = 
    5    for <variable> = <start> .. <stop> [ ++ | -- <step> ]  
    6        <statements> 
    7 }}} 
    8  
    93{{{ 
    104  numeric-for-statement = 
     
    126     <statements> 
    137}}} 
    14  
    15 The old-numeric-for syntax is deprecated. 
    168 
    179If <start> is not specified it defaults to 0.[[BR]] 
     
    2618while <variable> < <stop> 
    2719    ... statements.. 
    28     <variable> = <variable> + <step> 
     20    <variable> += <step> 
    2921}}} 
    3022i.e The <stop> value is exclusive to the loop counter range. 
     
    3729     print i   # prints values 1,2,3,4,5,6,7,8,9 
    3830 
     31  for i in 1 : 10  # can have spaces around : 
     32     print i 
     33 
    3934  for i in 5 
    40     print i     # prints values 0,1,2,3,4 
     35    print i    # prints values 0,1,2,3,4 
    4136 
    4237  for i in 7:5:-1 
    43     print i     # prints values 7,6 
     38    print i    # prints values 7,6 
    4439 
    4540  for e in 20:31:2 
     
    4843  for f in 7:5 
    4944    print f    # never executed 
     45 
     46  for i in someList.count 
     47    print i    # print the list indexes 
    5048}}} 
    5149 
     50== Old Syntax == 
     51 
     52The old-numeric-for syntax is deprecated. 
     53 
     54{{{ 
     55 old-numeric-for-statement = 
     56   for <variable> = <start> .. <stop> [ ++ | -- <step> ]  
     57       <statements> 
     58}}}