[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Fizzbuzz thread let rec f n s = if n > 100 then print_string
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 4
Thread images: 1
File: ocaml.png (58 KB, 420x420) Image search: [Google]
ocaml.png
58 KB, 420x420
Fizzbuzz thread
let rec f n s =
if n > 100
then print_string s
else f (n+1) (s ^ "\n" ^
let c x s2 s1 =
if n mod x = 0 then s2^s1 else s1
in
(fun x -> if x = "" then string_of_int n else x)
((c 3 "fizz") (c 5 "buzz" ""))
) in f 0 "";;
>>
let rec f n s =
if n > 100
then print_string s
else
f (n+1) (s ^ "\n" ^
let c x s2 s1 =
if n mod x = 0 then s1^s2 else s1 in
""
|> c 3 "fizz"
|> c 5 "buzz"
|> fun x -> if x = "" then string_of_int n else x
) in f 0 "";;
>>
>ocameme
>>
>>55615727
Anything wrong with it?
Thread replies: 4
Thread images: 1

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.