On 5/29/07, Mark J. Reed <[EMAIL PROTECTED]> wrote:
 My expectation before reading the delta was that negative counts
would do a reversal:

"123" x -1 = "321"

('a', 'b', 'c') xx -3 = ('c', 'b', 'a', 'c', 'b', 'a', 'c', 'b', 'a');

I don't know why I think that makes sense, but it was honestly my
first thought.  Does it make sense to anyone else?  Is there a
compelling reason I'm missing for having negative values behave as if
they were zero rather than adding some other potentially useful
functionality?
snip

In Perl 5 I commonly say things like

sub zeropad (
   my ($len, $s) = @_;
   my $slen = length $s;
   carp "the string $s is longer than the specified length $len" if
$slen > $len;
   return = 0 x  ($len - length($str)) . $str;
);

Which is roughly equivalent to doing a sprintf with the format "%0${len}d".

Reply via email to