in reply to Golfing Array_Pad
Forget splice
Nowsub p { # my($c,$s,@x)=@_;my@a=($s)x(-@x+abs$c);$c>0?(@x,@a):(@a,@x) ($*,$^,@#)=@_;@*=($^)x(-@#+abs$*);$*>0?(@#,@*):(@*,@#) #234567890123456789012345678901234567890123456789012345678 }
(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 |