Last active
November 15, 2017 19:25
-
-
Save melston/8dcfb2e26de693f5c1eaee42ca682e48 to your computer and use it in GitHub Desktop.
Another alternative FizzBuzz in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cycle x = Seq.initInfinite (fun _ -> x) |> Seq.concat | |
let zipWith f xs ys = Seq.zip xs ys |> Seq.map (fun (x,y) -> f x y) | |
let fizz = seq ["";"";"fizz"] |> cycle | |
let buzz = seq ["";"";"";"";"buzz"] |> cycle | |
let bang = seq ["";"";"";"";"";"";"bang"] |> cycle | |
let boom = seq ["";"";"";"";"";"";"";"";"";"";"boom"] |> cycle | |
let numbers = seq [1 .. 115] |> Seq.map string | |
let fizzBuzz3 = zipWith (+) bang boom | |
|> zipWith (+) buzz | |
|> zipWith (+) fizz | |
|> zipWith max numbers | |
fizzBuzz3 |> Seq.take 115 |> Seq.toList |> List.iter (printfn "%s") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment