in reply to Golfing Array_Pad

Forget splice

sub p { # my($c,$s,@x)=@_;my@a=($s)x(-@x+abs$c);$c>0?(@x,@a):(@a,@x) ($*,$^,@#)=@_;@*=($^)x(-@#+abs$*);$*>0?(@#,@*):(@*,@#) #234567890123456789012345678901234567890123456789012345678 }
Now 58 54 and still strict.

(Added) A word of explanation. If the multiplier is zero or negative, ($foo) x $bar returns an empty list. Punctuation variables are a vile trick.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Golfing Array_Pad [54]
by demerphq (Chancellor) on Jan 24, 2005 at 12:13 UTC

    With slightly easier to read vars:

    sub p{($a,$b,@_)=@_;@*=($b)x(-@_+abs$a);$a>0?(@_,@*):(@*,@_)}

    Also the prototype of abs makes this annoying, i thought you could reorder the -@_+abs$a to lose one of the operators but the abs() then requires parens. Nice one by the way. :-)

    ---
    demerphq