Created
April 22, 2015 13:10
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
public static IEnumerable<int> Div(this int numerator, int denominator) | |
{ | |
//return denominator == 0 | |
// ? Enumerable.Empty<int>() | |
// : new[] { numerator/denominator }; | |
if (denominator != 0) yield return numerator/denominator; | |
} | |
public static IEnumerable<int> DoSomeDivision(int denominator) | |
{ | |
return from a in 12.Div(denominator) | |
from b in a.Div(2) | |
select b; | |
} | |
... | |
var result = | |
from a in new[] { "Hello World!" } | |
from b in DoSomeDivision(2) | |
from c in new[] { new DateTime(2010, 1, 14) } | |
select (a + " " + b.ToString() + " " + c.ToShortDateString()); | |
Console.WriteLine(result.Any() ? result.First() : "Nothing"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment