-
-
Save rightfold/b5e12849ea35981a6615 to your computer and use it in GitHub Desktop.
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
use std::io | |
func fizzbuzz(n: Int): String | |
ensure out ~= %r{^fizz|buzz|fizzbuzz|\d+$} | |
{ | |
switch { | |
case n %% 15 => "fizzbuzz" | |
case n %% 5 => "buzz" | |
case n %% 3 => "fizz" | |
case true => itoa(n) | |
} | |
} | |
proc main() { | |
1..100 | |
|> map(fizzbuzz) | |
|> each(io::println) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment