Skip to content

Instantly share code, notes, and snippets.

@gbluma
Created February 23, 2011 21:46
Show Gist options
  • Save gbluma/841253 to your computer and use it in GitHub Desktop.
Save gbluma/841253 to your computer and use it in GitHub Desktop.
FizzBuzz.fsx
// ----------------------------------------------------------------------
// 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