Skip to content

Instantly share code, notes, and snippets.

@idavis
Created November 21, 2012 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idavis/4128478 to your computer and use it in GitHub Desktop.
Save idavis/4128478 to your computer and use it in GitHub Desktop.
FizzBuzz with PowerShell
filter Fizz-Buzz {
process {
$output = switch($_) {
{$_ % 3 -eq 0} {"Fizz"}
{$_ % 5 -eq 0} {"Buzz"}
default {$_}
}
$output -join ""
}
}
filter Fizz-Buzz2 {
process {
($_ = switch($_) { {$_ % 3 -eq 0} {"Fizz"} {$_ % 5 -eq 0} {"Buzz"} default {$_} }) -join ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment