>sub rotate { unshift @_, splice @_, shift @_; return @_ }
Curious. Here is one of my routines that rotates a vector (an array) either foward or reverse, any number of elements. Seems like we had a similar approach I just encapuslated with a bunch of logic and control.. # rotate elements around, arg is n and array sub rotate {return () unless $_[1]; die 'APL: rotate called with improper args' unless $_[0] && $_[1]; my $n=$_[0]; my @l=@{$_[1]}; my ($i, @lx) = (0); for ($i==0; $i<abs $n; $i++) {$lx=shift @l if $n>0; $lx=pop @l if $n<0; push @l,$lx if $n>0; unshift @l,$lx if $n<0; } return \@l; } * JAPC * Some girls like DIAMONDS, but I like PERL. _________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com