diff --git a/content/index.md b/content/index.md index 32818f0..3f7a287 100644 --- a/content/index.md +++ b/content/index.md @@ -11,18 +11,11 @@ Getting started? Head over to the [installation instructions](/getting_started/) ``` nimrod import tables, strutils -var wordFrequencies = initTable[string, int]() +var wordFrequencies = newCountTable[string]() for line in stdin.lines: for word in line.split(", "): - wordFrequencies[word] = wordFrequencies[word] + 1 + wordFrequencies.inc(word) -var maxFrequency = 0 -var mostFrequentWord: string -for word, frequency in wordFrequencies: - if frequency > maxFrequency: - maxFrequency = frequency - mostFrequentWord = word - -echo "The most frequent word is '", mostFrequentWord, "'" +echo "The most frequent word is '", wordFrequencies.largest, "'" ``` \ No newline at end of file