for-loops? with ZEN style.

import io::reader_util;

#[doc = "Main entry point"]
fn main(args: [str]) {
        let stdin = io::stdin();
        let input: [const u8] = stdin.read_whole_stream();
        for input.eachi {
                |i, x| {
                        io::print(uint::to_str(x as uint, 16u));
                        io::print(" ");
                        if i % 4u == 3u {
                                io::print(" ");
                        }
                        if i % 8u == 7u {
                                io::print("  ");
                        }
                        if i % 16u == 15u {
                                io::print("\n");
                        }
                }
        }
        io::print("\n");
}

Posted on 2012-04-20 19:27 with rust in 0.009 sec.