Created
November 28, 2014 13:42
-
-
Save EfrainReyes/c533b6437727cb94b2ab to your computer and use it in GitHub Desktop.
Fizz Buzz using functional C#
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
Enumerable.Range(1, 30).Select(num => | |
((Func<string[], string>) | |
(buzz => new string[]{ | |
buzz[((num + 2) % 3) / 2] + | |
buzz[((num + 4) % 5) / 4 * 2], | |
""+num | |
}.First(r => r != "")))(new[] { null, "fizz", "buzz"}) | |
).ToList().ForEach(s => Console.WriteLine(s)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Functional C# is a nightmare to read :)