Fix non-compiling code
This commit is contained in:
parent
da3708bf4e
commit
d812b28505
1 changed files with 4 additions and 4 deletions
|
|
@ -11,18 +11,18 @@ Getting started? Head over to the [installation instructions](/getting_started/)
|
|||
``` nimrod
|
||||
import tables, strutils
|
||||
|
||||
var wordFrequencies = initTable[string, int]
|
||||
var wordFrequencies = initTable[string, int]()
|
||||
|
||||
for line in stdin.lines:
|
||||
for word in line.split(", "):
|
||||
wordFrequencies[word] += 1
|
||||
wordFrequencies[word] = wordFrequencies[word] + 1
|
||||
|
||||
var maxFrequency = 0
|
||||
var maxFrequency = 0
|
||||
var mostFrequentWord: string
|
||||
for word, frequency in wordFrequencies:
|
||||
if frequency > maxFrequency:
|
||||
maxFrequency = frequency
|
||||
mostFrequentWord = word
|
||||
|
||||
echo "The most frequent word is '", word, "'"
|
||||
echo "The most frequent word is '", mostFrequentWord, "'"
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue