Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 1 of 13
Oct 02, 2009 at 8:05 PMI think it's more interesting if you don't bother, and just use where on group.Key, in which case if there is no grouping, you get the empty enumerable for free. I also used .Take(1) instead of FirstOrDefault(), then selected over the 0 or 1 element enumerable, instead of explicitly handling the empty case, which I find far too satisfying for words
C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 1 of 13
Oct 02, 2009 at 2:52 AMI'm pretty happy with this, though there really should be better "control" Linq operators.
static IEnumerable<T> QuickSort<T>(IEnumerable<T> enumerable) where T : IComparable<T> { var ps = enumerable.Take(1); var pt = from pivot in ps from x in enumerable.Skip(1) group x by 0 < x.CompareTo(pivot); var lt = pt.Where(g => !g.Key).SelectMany(g => QuickSort(g)); var gt = pt.Where(g => g.Key).SelectMany(g => QuickSort(g)); return lt.Concat(ps).Concat(gt); }