Last active
September 21, 2023 19:39
-
-
Save silasolla/ac26c33b69c8e29f75fd2081fdb06d6d to your computer and use it in GitHub Desktop.
FizzBuzz implementation written in Standard ML
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
| fun fizzBuzz n = | |
| let | |
| fun fizzBuzz' n' = | |
| case (n' mod 3, n' mod 5) of | |
| (0, 0) => "FizzBuzz" | |
| | (0, _) => "Fizz" | |
| | (_, 0) => "Buzz" | |
| | _ => Int.toString n' | |
| fun proc n' = | |
| let | |
| val _ = (print o fizzBuzz') n' | |
| val _ = print "\n" | |
| in | |
| () | |
| end | |
| val range = List.tabulate (n, fn n' => n' + 1) | |
| in | |
| List.app proc range | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment