on Sat, 18 May 2002 14:53:30 GMT, [EMAIL PROTECTED] (Beau E. Cox) wrote: > No, really - I showed you mine, now you show me yours!
#! /usr/bin/perl -w use strict; sub generator { my $lref = shift; my $minseq = shift; my $nextfun = shift; my $curpos = 0; my $lastpos = scalar(@$lref)-1; return sub { while ($curpos <= $lastpos) { my $result = [$lref->[$curpos]]; push @$result, $lref->[$curpos] while ++$curpos<=$lastpos && $lref->[$curpos] == $nextfun->($lref->[$curpos-1]); return $result if scalar(@$result) >= $minseq; } return; } } my @list = (1, 2, 3, 4, 10, 14, 15, 16, 20, 34, 35, 36); my $iter = generator(\@list, 3, sub {$_[0]+1}); while (my $r = $iter->()) { print "Found: @$r\n"; } -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]