in reply to Re^2: Golfing Array_Pad
in thread Golfing Array_Pad
Update:use strict; use warnings; use Test::More tests => 5; my @x = 1 .. 5; is_deeply([p( 3, 'x', @x)], [ @x ]); is_deeply([p(-3, 'x', @x)], [ @x ]); is_deeply([p( 7, 'x', @x)], [ @x, 'x', 'x' ]); is_deeply([p(-7, 'x', @x)], [ 'x', 'x', @x ]); @x = (); is_deeply([p(-4, 'x', @x)], [ 'x', 'x', 'x', 'x' ]); sub p {($a,$b,@x)=@_;@_=($b)x(abs@x-abs$a);@_=abs$a>@x?$a<0?(@_,@x):(@ +x,@_):@x}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Golfing Array_Pad
by demerphq (Chancellor) on Jan 24, 2005 at 16:20 UTC |