This is a little style and expressiveness test for various stream libraries. It is certainly not a proof of anything, so much as an ability to showcase how some basic features of streams fit together with different libraries.
Problem statement: given a library of streams, implement an API analogous to fgrep
, i.e., a literal string grepper.
Specifically, implement a function fgrep(test, filenames[, limit=10])
, which takes a source string, a list of filenames, and an optional concurrency limit, and produces a stream of Match
records { filename: string, lineNumber: number, line: string }
, representing all lines of all files that contain the string test
. For each matching record, filename
is the name of the file where the match was found, lineNumber
is the one-indexed line number where the match was found, and line
is the contents of the line where the match was found.
The limit
argument indicates the maximum number of concurrent filehandles that should b