Created
October 27, 2009 13:54
-
-
Save sgoguen/219575 to your computer and use it in GitHub Desktop.
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
void Main() | |
{ | |
var r = new Random().Values(0, 10).Let(list => list); | |
var l1 = r.Take(10); | |
var l2 = r.Take(10); | |
l1.SequenceEqual(l2).Dump("Should be equal"); | |
var l3 = r.Take(20); | |
l3.Take(10).SequenceEqual(l1).Dump("Should start with same sequence"); | |
var l4 = r.Take(20); | |
l3.SequenceEqual(l4); | |
} | |
} | |
public static class Extensions { | |
public static IEnumerable<int> Values( | |
this Random random, | |
int minValue, int maxValue) | |
{ | |
while (true) | |
yield return random.Next(minValue, maxValue); | |
} | |
public static IEnumerable<U> Let<T, U>(this IEnumerable<T> source, Func<IEnumerable<T>, IEnumerable<U>> f) { | |
return f(source); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment