Front page | perl.golf |
Postings from August 2002
Re: Reflections
Thread Previous
|
Thread Next
From:
Michael W Thelen
Date:
August 9, 2002 09:26
Subject:
Re: Reflections
Message ID:
20020809102452.B1685@attensity.com
On Fri, Aug 09, 2002 at 04:49:39PM +0100, Jasper McCrea wrote:
> > Another possibility may be to take the
> > first digit of $^T... an approach that may be valid for all places (if the
> > system clock is correct), but not for all times. In particular, it should fail
> > beginning April 17, 2033.
>
> $n=1
Drat! I missed that one! :-) Actually, I can't think of a way that using $^T
to get '1' could be short anyway. Except maybe '$^T%10', and then only test it
every 10 seconds.
Actually, this is kind of an interesting question... what are the various ways
that people have used to get a value of 1 into a variable? These aren't all
very good, but here's what I can think of:
- $n=1 is short, but may require parenthesizing
- ++$n is also short, and probably doesn't require parenthesizing
- use the return value of something else that needs to be done anyway, e.g.
$n=/.../
- $n=@+ or $n=@- after a successful match with no capturing parentheses
- $n=// where $_ is empty and no previously successful regexes, a la BoB's
factorial solution
- $n=!$| where $| is an example of some false value
- $n=!!$$ where $$ is an example of some true value
- use -w, thus setting $^W to 1, but winning a golf with a program that
produces no warnings may well be impossible
- $. when using -n0 or -p0
That exhausts my feeble brain. Any other tricks people have thought of?
-- Mike
--
Michael W. Thelen
eval unpack u,'M*"1C/2<P,BDN-"`U+C`A(RLG*3U^>2\A+48O82UZ+SME=F%L*"1C+B(G=2HGM+"
<Z,D<U4SU<(B%!.T9=5#HF-5(H)2%%/$907$`Z)B5#.E8U4BM@2&`G+EPD$+R(I.P``'
Thread Previous
|
Thread Next