From: Robert Dober Date: 2006-09-10T23:04:13+09:00 Subject: Re: How about Enumerable#find_pattern? ------=_Part_229090_30661296.1157897036877 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > > I'm thinking this: > foo=3D[1,2,3,4,5,6,5,4,3,2,1] > foo.find_pattern(5,6,5) #=3D> 4 (position of the start of this pattern) something a little bit more elaborated than this class Array def pattern( *args ) l =3D args.length c =3D dup while c.first(l) !=3D c do c.shift return nil if c.length < l end length - c.length end end could be put into your toolbox HTH Robert Alex > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_229090_30661296.1157897036877--