On Tue, 30 Jan 2001 rncarpio / yahoo.com wrote:

> Hmm, that'll do the trick for parallel iterators;  how about
> iterating through a list N at a time?  Do something similar
> with threads?

How about something like

module Enumerable
 	def each_n(n)
 		n_items = []
		each do |i|
			n_items << i
			if n_items.size == n
				yield n_items
				n_items = []
			end
		end
	end
end
			
[1,2,3,4,5,6].each_n(3) do |a,b,c|
	puts "#{a}, #{b}, #{c}"
end


#=> 1,2,3
#=> 4,5,6

-Avi