Created
January 27, 2013 10:33
-
-
Save vai/4647768 to your computer and use it in GitHub Desktop.
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
| #pragma indent | |
| using System.Linq | |
| using System.Console | |
| module Program | |
| Main() : void | |
| // Specify our pairs of ([divisors], text) to override | |
| def pairs = [([3,5], "FizzBuzz"), ([3], "Fizz"), ([5], "Buzz")] | |
| // Allow retrieval of the appropriate word | |
| def wordFor (x) | |
| pairs.FirstOrDefault( y => y[0].All( i => x % i == 0) )[1] ?? $"$x" | |
| // Output our results for the set range | |
| foreach ( i in [1..100] ) WriteLine( wordFor(i) ) | |
| _ = ReadLine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment