Created
          November 21, 2012 23:15 
        
      - 
      
 - 
        
Save idavis/4128478 to your computer and use it in GitHub Desktop.  
    FizzBuzz with PowerShell
  
        
  
    
      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
    
  
  
    
  | 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