Front page | perl.fwp |
Postings from February 2005
Re: "Secret" operators
Thread Previous
|
Thread Next
From:
Peter Haworth
Date:
February 3, 2005 03:45
Subject:
Re: "Secret" operators
Message ID:
PGM.20050203114513.25810.5341@edison.ioppublishing.com
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 pmh@edison.ioppublishing.com
"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
Thread Previous
|
Thread Next