2010-07-22 14:11:39 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-01-23 16:59:00 -06:00
|
|
|
fn range(a: int, b: int, it: fn(int)) {
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (a < b);
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut i: int = a;
|
2011-10-21 06:14:28 -05:00
|
|
|
while i < b { it(i); i += 1; }
|
2010-07-22 14:11:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut sum: int = 0;
|
2012-06-30 18:19:07 -05:00
|
|
|
range(0, 100, |x| sum += x );
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, sum);
|
2011-08-15 23:54:52 -05:00
|
|
|
}
|