Fix non-compiling code
This commit is contained in:
parent
da3708bf4e
commit
d812b28505
1 changed files with 4 additions and 4 deletions
|
|
@ -11,11 +11,11 @@ Getting started? Head over to the [installation instructions](/getting_started/)
|
||||||
``` nimrod
|
``` nimrod
|
||||||
import tables, strutils
|
import tables, strutils
|
||||||
|
|
||||||
var wordFrequencies = initTable[string, int]
|
var wordFrequencies = initTable[string, int]()
|
||||||
|
|
||||||
for line in stdin.lines:
|
for line in stdin.lines:
|
||||||
for word in line.split(", "):
|
for word in line.split(", "):
|
||||||
wordFrequencies[word] += 1
|
wordFrequencies[word] = wordFrequencies[word] + 1
|
||||||
|
|
||||||
var maxFrequency = 0
|
var maxFrequency = 0
|
||||||
var mostFrequentWord: string
|
var mostFrequentWord: string
|
||||||
|
|
@ -24,5 +24,5 @@ for word, frequency in wordFrequencies:
|
||||||
maxFrequency = frequency
|
maxFrequency = frequency
|
||||||
mostFrequentWord = word
|
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