Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2014 01:36
Show Gist options
  • Save anonymous/eda0623f4d143d797cdc to your computer and use it in GitHub Desktop.
Save anonymous/eda0623f4d143d797cdc to your computer and use it in GitHub Desktop.
import strutils
const SIZE = 8192
var
rlen = 0
totlen = 0
buf = alloc(SIZE)
lc = 0
totlines = 0
while true:
rlen = stdin.readBuffer(buf, SIZE)
if rlen == 0: break
# does not like the next line.
# how to make it a "string"?
lc = buf.countLines
echo lc
totlines.inc(lc)
totlen.inc(rlen)
echo totlen
echo lc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment