Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:16
Show Gist options
  • Save rightfold/b5e12849ea35981a6615 to your computer and use it in GitHub Desktop.
Save rightfold/b5e12849ea35981a6615 to your computer and use it in GitHub Desktop.
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