Tables: make toCountTable actually count the elements of the input openArray.
This commit is contained in:
parent
53cf0b2c24
commit
c36d7ffc7c
1 changed files with 1 additions and 1 deletions
|
|
@ -968,7 +968,7 @@ proc initCountTable*[A](initialSize=64): CountTable[A] =
|
|||
proc toCountTable*[A](keys: openArray[A]): CountTable[A] =
|
||||
## creates a new count table with every key in `keys` having a count of 1.
|
||||
result = initCountTable[A](rightSize(keys.len))
|
||||
for key in items(keys): result[key] = 1
|
||||
for key in items(keys): result.inc key
|
||||
|
||||
proc `$`*[A](t: CountTable[A]): string =
|
||||
## The `$` operator for count tables.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue