Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@sharktits It's not about lines. I can put a 10.000 line js code in one line xD
Yea but I know this approach too (from our dear lord Tom Scott) -
@BambuSource yeah, i separated logical parts into lines, and kept the standard sybtax for that reason
-
Not my code, but I love how concise Haskell can be:
```
fizzbuzz :: Int -> String
fizzbuzz n = (test 3 "fizz" . test 5 "buzz") id (show n)
where test d s x | n `mod` d == 0 = const (s ++ x "")
| otherwise = x
``` -
@sharktits i did it like that too (I have it somewhere on my youtube channel)
Tho I saw somebody who made it in Haskell (can't remember exactly which language).
It didn't compile, but the error was genious, as the error log itself was the fizzbuzz -
@bioDan FizzBuzz is the only thing making it so hard to make it a one-liner.
http://wiki.c2.com/?FizzBuzzTest -
bioDan61597y@daintycode oh lol thanks!
I got confused by OP's gf code.
Apologies @ObiSwagKenobi
@OPgirlfriend, your output is incorrect. -
Meta33867yHmm, if the space is not valid, then I got wrong intel when I read about it the other day and made that code up there for it 😯
-
athlon173227yfor (int i = 0; i < 100; i++) {
string output = “”;
if (i% 3 == 0) output += “fizz”;
if (i % 5 == 0) output += “buzz”;
if (output == “”) output = i;
Console.WriteLine(output);
} -
stisch48147ylet Ruby set you free
(0..100).each do |i|
p "#{i} #{i % 3 == 0 ? 'Fizz' : ''}#{i % 5 == 0 ? 'Buzz' : ''}"
end -
@ewpratten I watched it once. No idea what it is/was about but it was hell of funny
@AlexDeLarge @Alice
I don't know if I love or hate you -
@BambuSource nothin, custom pin xD currently still at work in deep shit, but rant looks interesting xD
-
Brolls31557yCouple of ways of doing it that I've got in F#.
First is probably the one I prefer, although the second one is a nice demo of active patterns. -
Brolls31557y@AlexDeLarge one of my favourite things there (total nerd) is that the (printfn "%s") is actually type checked at compile time.
F# does some magic with format strings where they become functions in their own right, so if you're not pumping the correct types into the function using the format string the compiler will moan. -
Brolls31557y@AlexDeLarge I find myself constantly writing up versions of the common monads etc when I'm working on a C# project as well.
I find working without certain functional luxuries a real pain these days. -
@LicensedCrime there you go:
https://pastebin.com/raw/5W3vWwsu
copy, paste into your console and run :) -
@LicensedCrime efficient? Not at all! Still it's pretty "funny" how implicit type coercion works in JS
Related Rants
-
this6About 18 months ago my non-technical Manager of Applications Development asked me to do the technical intervie...
-
iSwimInTheC8Newcomer: I can do fizzbuzz in 6 lines of code Experienced: I can do fizzbuzz in 3 lines of code Professiona...
-
RiderExMachina4There's always that great feeling of accomplishment when you finish a project. Even if it is only 23 lines. ...
I challenged my girlfriend (and myself) for the FizzBuzz thingy. I did it in js (because I suck at js) and she in Java. I never saw such a way to write FizzBuzz. Turns out she forgot there is a thing called modulo operator.
I know there are more elegant ways to solve it! Feel free to post your favorites.
rant
"multiple of" taken seriously
fizzbuzz