From: Rick DeNatale Date: 2007-04-30T10:43:52+09:00 Subject: Re: cyclic array On 4/28/07, Xavier Noria wrote: > > This is a possible approach: > > module Enumerable > def each_cycle(window, start=0) > (start...length+start).each do |i| > yield((i..i+window).map {|n| self[n % length]}) > end > end > end This method won't work for Enumerables in general, although I guess it does work for Arrays. Not all enumerables have one or both length or [] methods. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/