On Wed, 2 Feb 2005 16:20:05 +0200, Vladi Belperchinov-Shabanski wrote:
> On Wed, 2 Feb 2005 12:33:35 +1100 (EST)
> > IIRC, Ton's ~- invention allows you to eliminate the parens in:
> >
> >     $y = ($x-1)*4;
> >
> > by using instead:
> >
> >     $y = ~-$x*4;
> >
> > saving a whopping two strokes. This trick should work on any twos
> > complement machine -- and I'm not aware of any perl running on any
> > non twos complement machine.
>
> will not work if $x < 0

It does if you C<use integer>, but that's no good for golf, (unless
you need 6 decrements, of course).

Incidentally, -~$x will increment negative numbers, but fails on >=0
for the same reason.

-- 
        Peter Haworth   [EMAIL PROTECTED]
"Ah, you're only calling [perl threads] experimental because it's slow,
 broken in spots, and has problems with backwards compatibility. What kind
 of labelling is that? (And where does it leave Windows NT?)"
                -- Dan Sugalski

Reply via email to