Skip to content

Instantly share code, notes, and snippets.

@xeno-by
Created June 25, 2013 13:25
Show Gist options
  • Save xeno-by/5858405 to your computer and use it in GitHub Desktop.
Save xeno-by/5858405 to your computer and use it in GitHub Desktop.
withFile(file) { c =>
val bytes: Producer[ImmutableBuffer[Byte,Read]] =
bytechannels.read_channel_bytes(c, directBuffers=true)
val chars = Producer[ImmutableBuffer[Char,Read]] =
bytes convert charsets.decoder()
val wordCount: Consumer[ImmutableBuffer[Char, Read], Long] =
charchannels.words convert utils.counter
val lineCount: Consumer[ImmutableBuffer[Char, Read], Long] =
charchannels.lines convert utils.counter
val allCount: Consumer[ImmutableBuffer[Char,Read], String] =
lineCount zip wordCount zip utils.lengthCounter(_.remaining) map {
case((lc, wc), cc) => "lines: %d, words %d, chars %s" format (lc,wc,cc)
}
chars into allCount result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment