Description
Streams is designed to be a lightweight streams processing library written in Ruby. I intend to keep this very small (infact, it’s unlikely to change at all), and have added most common methods to make it immediately useable.
Example
require ‘streams’
class Stream
def sieve
Stream.new( head ) { tail.select { | n | n % head > 0 }.sieve }
end
end
module Math
PRIMES = 2.enumerate.sieve
end
>> Math::PRIMES.at( 30 )
> 127
>> Math::PRIMES.select { | n | n > 100 }.take( 50 )