Created
February 23, 2011 21:46
-
-
Save gbluma/841253 to your computer and use it in GitHub Desktop.
FizzBuzz.fsx
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
// ---------------------------------------------------------------------- | |
// Synchronous (useful) | |
let fizzbuzz n = | |
match n with | |
| n when (n % 3 = 0) -> printfn "Fizz" | |
| n when (n % 5 = 0) -> printfn "Buzz" | |
| n -> printfn "%d" n | |
[1..100] |> Seq.iter (fun n -> fizzbuzz n) | |
// ---------------------------------------------------------------------- | |
// Async (not useful) | |
let fizzbuzz n = | |
match n with | |
| n when (n % 3 = 0) -> printfn "Fizz" | |
| n when (n % 5 = 0) -> printfn "Buzz" | |
| n -> printfn "%d" n | |
[1..100] | |
|> Seq.map (fun n -> async { fizzbuzz n } ) | |
|> Async.Parallel | |
|> Async.RunSynchronously |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment