Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Last active December 14, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cromwellryan/5092417 to your computer and use it in GitHub Desktop.
Save cromwellryan/5092417 to your computer and use it in GitHub Desktop.
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