Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fizzbuzz in Rust

Name: Anonymous 2015-04-05 14:41

Observe how elegant this is:
fn main() {
for i in range(1i, 101){
let value = i.to_string();
println!("{}", match (i % 3, i % 5) {
(0,0) => "FizzBuzz",
(0,_) => "Fizz",
(_,0) => "Buzz",
_ => value.as_slice()
});
}
}

Name: Anonymous 2015-04-05 18:18

>>1
import Control.Monad

main = forM_ [1..100] $ \n -> putStrLn $
case (mod n 3, mod n 5) of
(0, 0) -> "FizzBuzz"
(0, _) -> "Fizz"
(_, 0) -> "Buzz"
_ -> show n

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List