Created
September 26, 2023 16:04
-
-
Save pocarist/b7b4c80aa0bc465ab1ed0c4e4088978a to your computer and use it in GitHub Desktop.
FizzBuzz written using F# sequence
This file contains hidden or 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 fizz = | |
Seq.initInfinite (fun i -> if (i+1) % 3 = 0 then "Fizz" else "") | |
let buzz = | |
Seq.initInfinite (fun i -> if (i+1) % 5 = 0 then "Buzz" else "") | |
let fizzbuzz = | |
Seq.mapi2 (fun i f b -> match f + b with "" -> string (i + 1) | x -> x) fizz buzz | |
fizzbuzz | |
|> Seq.take 100 | |
|> Seq.iter (printfn "%s") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment