On Thu, May 30, 2013 at 6:26 PM, Renato Lenzi <[email protected]> wrote:
> with
> fot int::range(low,hi)
> i can loop from low to h1-1
>
> with
> for int::range_step(low, hi, step)
> i can loop for low to hi-1 with step "step"
>
> with
> for int::range_rev(hi, low)
> i can loop from hi to low, reverse mode
>
> but... how can loop from hi to low with step other than 1? range_rev_step is
> obviously undefined....

range_step works fine for this, too:

fn main() {
    for int::range_step(10, 1, -2) |i| {
        io::print(fmt!("%d ", i));
    }
}

prints "10 8 6 4 2".  The first and second arguments are "start" and
"stop" rather than "lo" and "hi".

Lindsey
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to