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: Format-bot 2015-04-05 15:49

#include "void.h" //gist.github.com/FrozenVoid/87e6ad6212ac9ce496e0#file-void-h"
STDSTART for(u8 i=1; i < 101; i++){
switch(!(i%3) + ((!(i%5))<<1)){ //0:x 0:x->1:0 1:0
case 0b00:
p(i, crlf);
break;
case 0b01:
p("Fizz", crlf);
break;
case 0b10:
p("Buzz", crlf);
break;
case 0b11:
p("Fizzbuzz", crlf);
break; }}
STDEND

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