Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fizzbuzz done in F# & Coffeescript
firsthund = [1..100]
isfizz = (x) ->
x % 3 == 0
isbuzz = (x) ->
x % 5 == 0
handle = (x) ->
if isfizz(x) and isbuzz(x) then 'fizzbuzz'
else if isfizz x then 'fizz'
else if isbuzz x then 'buzz'
else x
let firstHundred = [1..100]
let isbuzz x =
x % 5 = 0
let isfizz x =
x % 3 = 0
let handleNum x =
match x with
| (x) when isfizz x && isbuzz x -> "fizzbuzz"
| (x) when isfizz x -> "fizz"
| (x) when isbuzz x -> "buzz"
| _ -> x.ToString()
//if isfizz x then "fizz" else x.ToString()
List.map handleNum firstHundred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.