Sha256: 483228e0261a24e9de8d97c9a610febdddb49b3c7aa2203b40a460467532b090
Contents?: true
Size: 715 Bytes
Versions: 396
Compression:
Stored size: 715 Bytes
Contents
using System.Collections.Generic; using System.Linq; public static class ParallelLetterFrequency { public static Dictionary<char, int> Calculate(IEnumerable<string> texts) { return texts.AsParallel().Aggregate(new Dictionary<char, int>(), AddCount); } private static Dictionary<char, int> AddCount(Dictionary<char, int> target, string text) { foreach (var kv in text.ToLower().Where(char.IsLetter).GroupBy(c => c)) { if (target.ContainsKey(kv.Key)) { target[kv.Key] += kv.Count(); } else { target[kv.Key] = kv.Count(); } } return target; } }
Version data entries
396 entries across 396 versions & 1 rubygems