Skip to content

Instantly share code, notes, and snippets.

@EfrainReyes
Created November 28, 2014 13:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EfrainReyes/c533b6437727cb94b2ab to your computer and use it in GitHub Desktop.
Save EfrainReyes/c533b6437727cb94b2ab to your computer and use it in GitHub Desktop.
Fizz Buzz using functional C#
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));
@jangeador
Copy link

Functional C# is a nightmare to read :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment