Created
May 27, 2015 10:54
-
-
Save Araq/b40932a30b9dbb824364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threadpool, tables, strutils | |
var db {.threadvar.}: CountTable[string] | |
proc rawPut(key: string) = | |
inc(db, key) | |
proc rawInit() = | |
db = initCountTable[string]() | |
proc put(key: string) = | |
pinnedSpawn 0, rawPut(key) | |
proc init = | |
pinnedSpawn 0, rawInit() | |
proc rawGet(): string = | |
db.sort() | |
result = db.largest()[0] | |
proc getMax(): string = | |
let flow = pinnedSpawn(0, rawGet()) | |
result = ^flow | |
proc main = | |
init() | |
for x in split(readFile("readme.txt")): | |
put x | |
echo getMax() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment