using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { File.ReadAllText(args[0]). Split("all non-alpha characters here".ToCharArray()). GroupBy(x => x, (x, y) => new {word = x, count = y.Count()}). OrderBy(x => x.count). Reverse(). Take(int.Parse(args[1])). ToList(). ForEach(x => Console.WriteLine(x.word, "=", x.count)); } }
no subject
Date: 2013-06-20 10:50 pm (UTC)using System; using System.IO; using System.Linq; class Program { static void Main(string[] args) { File.ReadAllText(args[0]). Split("all non-alpha characters here".ToCharArray()). GroupBy(x => x, (x, y) => new {word = x, count = y.Count()}). OrderBy(x => x.count). Reverse(). Take(int.Parse(args[1])). ToList(). ForEach(x => Console.WriteLine(x.word, "=", x.count)); } }а если бы в IEnumerable был метод ForEach, то и 12. глубинный смысл отсуствия там оного меня угнетает.no subject
Date: 2013-06-20 10:55 pm (UTC)no subject
Date: 2013-06-21 07:55 pm (UTC)