News for hackers. Stuff that matters.
Re:LINQ Ruined My Favorite Interview Question by louthy on Thursday July 11, 2013 @01:57PM (#6027768)
The OP blog-post doesn't really represent it succinctly in C#. This is the most succinct way I could think of:

  var top = (from w in text.Split(' ') 
             group w by w into g 
             orderby g.Count() descending 
             select g.Key).Take(10);
Re:LINQ Ruined My Favorite Interview Question by cmircea on Thursday July 11, 2013 @07:05PM (#6029873)
Though that will result in a lot more calls to Count(). A let would fix that.
Re:LINQ Ruined My Favorite Interview Question by voltagex_ on Friday July 12, 2013 @01:24AM (#6031074)
I really really really should learn more Linq. Where would I use let, and why?
Re:LINQ Ruined My Favorite Interview Question by cmircea on Friday July 12, 2013 @02:48AM (#6031270)

    from word in text.Split(' ') 
    group word by word into g
    let count = g.Count()
    orderby count descending 
    select g.Key
Under the covers when it is compiled it's turned into a select. That way it it only does N counts, not potentially N log N (for each comparison in the orderby), where N is the number of items you enumerate (so if you .Take() just 10 it doesn't really matter).
Re:LINQ Ruined My Favorite Interview Question by louthy on Friday July 12, 2013 @07:43AM (#6032066)
Indeed! It wouldn't be quite as concise though, which was kind of my point :)