Created
June 25, 2013 13:25
-
-
Save xeno-by/5858405 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
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