Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FizzBuzz version using match pattern
- let fb nn =
- // get string associated with value
- let inline s n =
- // tuple if number is multiple of 3 and/or of 5
- let inline t v =
- (v % 3 = 0, v % 5 = 0)
- // what case is?
- match (t n) with
- | (true,false) -> "Fizz"
- | (false,true) -> "Buzz"
- | (true,true) -> "FizzBuzz"
- | _ -> n.ToString()
- // List of all strings
- List.map s [1..nn]
- // --------------------------------------
- // examples
- // first 100
- printfn "%A" (fb 100)
- // WARNING: Over a 1.000.000 values!!!!
- printfn "%A" (fb 1000000 |> Array.ofList).[40999..41099]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement