[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Fizzbuzz

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 27
Thread images: 3

File: flap.gif (269KB, 393x450px) Image search: [Google]
flap.gif
269KB, 393x450px
This is the ideal fizzbuzz. You may not like it, but this is what peak extensibility looks like:

(: fizzbuzz (fixnum (list-of (list fixnum symbol)) -> boolean))
(define (fizzbuzz limit conds)
(letrec ((itr (lambda (n)
(if (> n limit)
#t
(begin (let ((unfizzed? (foldl (lambda (acc x)
(if (= 0 (modulo n (car x)))
(begin (display (cadr x))
#f)
acc))
#t
conds)))
(if unfizzed?
(display n)))
(newline)
(itr (fx+ 1 n)))))))
(itr 1)))


#;> (fizzbuzz 21 '((3 fizz)(5 buzz)(7 bob)))
1
2
fizz
4
buzz
fizz
bob
8
fizz
buzz
11
fizz
13
bob
fizzbuzz
16
17
fizz
19
buzz
fizzbob
#t
>>
File: bm0qc6l.jpg (70KB, 1280x720px) Image search: [Google]
bm0qc6l.jpg
70KB, 1280x720px
>>62417800
You're really gonna do this, aren't you?
>>
>>62417984
Do what?
Show me a better fizzbuzz algorithm.
>>
File: apl-fizzbuzz.png (19KB, 1024x37px) Image search: [Google]
apl-fizzbuzz.png
19KB, 1024x37px
>>62417998
fucking newfag brainlets
>>
>>62418053
whats that cute font
>>
>>62418053
Can you extend it to handle other cases at runtime?
>>
>>62417800
Cleaner, if slightly less performant:

(define (fizzbuzz limit conds)
(for-each (lambda (n)
(let ((unfizzed? (foldl (lambda (acc x)
(if (= 0 (modulo n (car x)))
(begin (display (cadr x))
#f)
acc))
#t
conds)))
(if unfizzed?
(display n)))
(newline))
(iota limit 1)))
>>
>>62418179
>performant
not a real word pajeet
>>
>>62418188
Answer my question
>>
>>62418217
What's your question again?
>>
>>62418236
Can you extend >>62418053 to handle other cases at runtime?
It looks like your conditions are hardcoded into the function definition, just like any C imperative code monkey would do. What about fizzbaz? fizzbar? buzzbob?
>>
>>62418268
Also having a separate case for "FizzBuzz" is silly
>>
>>62418188
>not a real word pajeet

https://en.wiktionary.org/wiki/performant

Hilarious projection there, subhuman.
>>
>>62418290
>a dictionary anybody can edit!
lol
>>
>>62418465
Answer my question
>>
>>62418489
You asked for a fizzbuzz but it's obvious how you can extend it if you can read the code.

Can you read the code, brainlet Pajeet?
>>
>>62418465
>He didn't read the quotations

Lel, you are below subhuman, in fact using the word human to describe you would be an insult to the rest of humanity.
You are just trash.
>>
>>62418531
>at runtime
>>
>>62418531
You still didn't explain why you have an explicit case for 'FizzBuzz' either. That's just sad.
>>
bampu pantsu
>>
div5(X) :- 0 is X mod 5.
div3(X) :- 0 is X mod 3.

fizzbuzz(X, Max) :- (div3(X), div5(X), writeln('FizzBuzz');
div5(X), writeln('Buzz');
div3(X), writeln('Fizz');
writeln(X)), !,
X < Max,
X1 is X+1,
fizzbuzz(X1, Max).

fizzbuzz :- fizzbuzz(1, 100).
>>
>>62418053
>>62418096
pls
>>
>>62420619
>separate condition for 'fizzbuzz'
ummm try again sweetie
>>
>>62420679
>>62418590

This is you, right? It was just something stupid I put together in a language not meant at all for shit like fizz buzz. But it's real cool how you think you're a hotshot coder cause you only write optimal fizzbuzzes. You must be able to get any job you want, 300k starting.
>>
>>62420690
You sound mad honey. Hit the books and come back to us when your ready...
>>
>>62417800
Please DO NOT post my wife, Ritsu, on this FAGGOT webpage. Thanks.
>>
up
Thread posts: 27
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.