let the fun begin!

1)
use List::MoreUtils 'pairwise';
print pairwise { $b - $a } @{...@inc[0..$#inc-1]]}, @{...@inc[1..$#inc]]};

2)
local $. = $inc[0];
print map { -$.+($.=$_) } @inc[1..$#inc];

и его деструктивная версия

local $. = shift @inc;
print map { -$.+($.=$_) } @inc;


On Fri, Aug 13, 2010 at 11:09:50AM +0200, Andrew Shitov wrote:
> Привет!
> 
> А кто умеет упростить вот это, применив всякие map/grep?
> 
> 
> my @inc = (0, 10, 20, 35, 55);
> my @uni;
> for (my $c = 1; $c != scalar @inc; $c++) {
>     push @uni, $inc[$c] - $inc[$c - 1];
> }
> say Dumper \...@uni;
> 
> 
> -- 
> Andrew Shitov
> ______________________________________________________________________
> [email protected] | http://shitov.ru
> --
> Moscow.pm mailing list
> [email protected] | http://moscow.pm.org

-- 
Sincerely,
        Dmitry Karasik

--
Moscow.pm mailing list
[email protected] | http://moscow.pm.org

Ответить