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

Pages: 1-

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 15:00

>>1
#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

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

Name: Anonymous 2015-04-05 15:51

>>3 Just like the swedish chef bot:waste of space.

Name: Anonymous 2015-04-05 15:56

>>4
}
}
}
}
}
}
}
}

Name: Anonymous 2015-04-05 16:51

Is FrozenVoid back? I've seen many unironic cases of void.h as of lately. It's hard to believe anyone else would use it.

Name: Anonymous 2015-04-05 17:12

>>6
(Autismal shitstorm incoming). Yes, i'm FrozenVoid and i've been posting here for quite awhile. Deal with it.
If the last TOR nodes get banned i'll leave of course, but i don't like to(*tempting fate*). To not trigger everyone, i'll stay anonymous.

Name: Anonymous 2015-04-05 17:21

>>7
You're the one who's always complaining about the blacklists?

Name: Anonymous 2015-04-05 17:25

>>8 I've only done that a few times, there other TOR users here.

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

Name: Anonymous 2015-04-05 18:21

>>8
I am not the degenerate furfaggot and I have also complained about the blacklists. Sometimes I go a day without seeing the ban message, other times it takes four or five identity changes. It's so fickle.

Name: Anonymous 2015-04-05 18:53

>>10
Haskell monadic iterators are still 1.5-3x slower than imperative loops, I've benchmarked.

Name: Anonymous 2015-04-05 19:38

>>12
Write better benchmarks.

Name: Anonymous 2015-04-05 19:43

>>13
Why don't you write a benchmark in which the Haskell forM_ is within 10% of a C for loop and show it to us, smartiepants?

Name: Anonymous 2015-04-06 0:04

>>12
import Data.DList hiding (foldr)

main = putStr $ toList $ foldr (append . fizzer) empty [1..100]
where
fizzer n = case (mod n 3, mod n 5) of
(0, 0) -> fromList "FizzBuzz\n"
(0, _) -> fromList "Fizz\n"
(_, 0) -> fromList "Buzz\n"
_ -> fromList $ show n ++ "\n"

Name: Anonymous 2015-04-06 6:56

>>15
What is this supposed to mean, anyway?

Name: Anonymous 2015-04-06 7:07

>>16 It builds a string from all fizzbuzz N values and then prints the entire string at once.

Name: Anonymous 2015-04-06 7:14

>>17
But that's not a benchmark to measure the performance of Haskell iterators vs imperative loops. 100 elements aren't even sufficient to benchmark anything.

Name: Anonymous 2015-04-06 7:35

>>18 I didn't wrote it.

Name: Anonymous 2015-04-06 9:46

Keep posting your shitty Rust threads all you want, but I'll NEVER bow down and use your shit SJW beta-faggot language.

Name: Anonymous 2015-04-07 6:34

HEY ALL CHECK OUT MY FIBS

Name: Anonymous 2015-04-07 12:35

>>21
Nice. My dubs are better though.

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