I often use tri-state flags, with possible value true (1), false (0), or
undetermined (undef).
The question is: how do you test for one of the flags, in particular for
0, without warnings?
For true, it's easy:
$flag
For undef, it's not hard:
!defined $flag
But for 0?
Note th
What's really stumping me is that there has to be a shorter solution for
wc.pl (mine is 23), but I haven't been able to get past the need for printf
(at least, not for a shorter solution). Has anyone managed to do it without
it?
I also vote that we close this soon and unveil the winners. I have a
Current Leaderboard
---
1. 89Eugene van der Pijll
2. 92Piers Cawley
3. 92Rick Klement
4. 92Japhy
5. 94Yanick
6. 94Rick Delaney
7. 94^ Damian James
8. 95Ronald J Kimball
9. 95Robin Houston
10. 95- BooK
11. 97Keit
[EMAIL PROTECTED] writes:
> A quality test program is vital to a successful game.
> Ideally, you would like to just say: "If it passes the test
> program, it is OK". I could even envisage a 100% automated
> system where you would not need a human arbiter at all.
>
> I think it is also crucial to h
Brad Greenlee <[EMAIL PROTECTED]> writes:
> What's really stumping me is that there has to be a shorter solution for
> wc.pl (mine is 23), but I haven't been able to get past the need for printf
> (at least, not for a shorter solution). Has anyone managed to do it without
> it?
Gah! You've obvio
Piers Cawley <[EMAIL PROTECTED]> writes:
> Brad Greenlee <[EMAIL PROTECTED]> writes:
>
>> What's really stumping me is that there has to be a shorter solution for
>> wc.pl (mine is 23), but I haven't been able to get past the need for printf
>> (at least, not for a shorter solution). Has anyone m
En réponse à Brad Greenlee <[EMAIL PROTECTED]>:
> What's really stumping me is that there has to be a shorter solution
for
> wc.pl (mine is 23), but I haven't been able to get past the need for
> printf (at least, not for a shorter solution). Has anyone managed to do
> it
without it?
My wc.pl is
BooK <[EMAIL PROTECTED]> writes:
> En réponse à Brad Greenlee <[EMAIL PROTECTED]>:
>
>> What's really stumping me is that there has to be a shorter solution
for
>> wc.pl (mine is 23), but I haven't been able to get past the need for
>> printf (at least, not for a shorter solution). Has anyone man
On Wed, Dec 05, 2001 at 03:30:07AM +0100, Bart Lateur wrote:
> I often use tri-state flags, with possible value true (1), false (0), or
> undetermined (undef).
>
> The question is: how do you test for one of the flags, in particular for
> 0, without warnings?
>
> For true, it's easy:
>
>
On Tue, Dec 04, 2001 at 07:06:01PM -0800, Brad Greenlee wrote:
> What's really stumping me is that there has to be a shorter solution for
> wc.pl (mine is 23), but I haven't been able to get past the need for printf
> (at least, not for a shorter solution). Has anyone managed to do it without
> it
On Wed, Dec 05, 2001 at 04:32:49AM -0500, Michael G Schwern wrote:
> On Wed, Dec 05, 2001 at 03:30:07AM +0100, Bart Lateur wrote:
> > I often use tri-state flags, with possible value true (1), false (0), or
> > undetermined (undef).
> >
> > The question is: how do you test for one of the flags, i
Michael G Schwern <[EMAIL PROTECTED]> writes:
> On Tue, Dec 04, 2001 at 07:06:01PM -0800, Brad Greenlee wrote:
>> What's really stumping me is that there has to be a shorter solution for
>> wc.pl (mine is 23), but I haven't been able to get past the need for printf
>> (at least, not for a shorter
On Wed, Dec 05, 2001 at 10:43:14AM +0100, Sven Neuhaus wrote:
> On Wed, Dec 05, 2001 at 04:32:49AM -0500, Michael G Schwern wrote:
> > On Wed, Dec 05, 2001 at 03:30:07AM +0100, Bart Lateur wrote:
> > > I often use tri-state flags, with possible value true (1), false (0), or
> > > undetermined (und
On Wed, Dec 05, 2001 at 10:43:14AM +0100, Sven Neuhaus wrote:
> Looks like "~" doesn't trigger a warning on undef.
>
> So
> ~$a ? $a ? 3 : 2 : 1
>
> will yield 3 for true, 2 for false, 1 for undef.
That's no good, repetition of the expression is a no-no.
Note that "$flag" may well be an ex
> defined $flag && !$flag
> So, who does better?
defined ($var = $flag) && !$var
$flag is only evaluated once. :)
Mike Lambert
On Tue, Dec 04, 2001 at 08:04:11PM +0100, Philip Newton wrote:
> On Mon, 3 Dec 2001 13:17:11 -0500 (EST), [EMAIL PROTECTED] (Jeff 'Japhy'
> Pinyan) wrote:
>
> > I think the golfers among us should pool our efforts (after the rowdy,
> > cut-throat competition ends, of course!) to amass a list of c
On Wed, Dec 05, 2001 at 05:11:43AM -0500, Michel Lambert wrote:
> > defined $flag && !$flag
> > So, who does better?
>
>
> defined ($var = $flag) && !$var
>
> $flag is only evaluated once. :)
But Bart said he wanted to test for 0. The test above, and several of
the other proposals don't disti
On Wed, Dec 05, 2001 at 04:56:34AM -0500, Michael G Schwern wrote:
> On Wed, Dec 05, 2001 at 10:43:14AM +0100, Sven Neuhaus wrote:
> > Looks like "~" doesn't trigger a warning on undef.
> >
> > So
> > ~$a ? $a ? 3 : 2 : 1
> >
> > will yield 3 for true, 2 for false, 1 for undef.
>
> That's no go
Jeff 'japhy' Pinyan wrote:
>
> Geez, I have three different solutions for tail.pl, ALL the same length
> (19 chars). Has someone gotten below 19?
>
I stuck on 19 too and I don't think it can be shorter :)
(this could sound like trying to put out a fire with gasoline
but I really think so
[EMAIL PROTECTED] schreef op 05 december 2001:
> Given that tsanta.pl has many loopholes, a panel of experts will
> than examine the leading solutions for correctness (disqualifying
> an entry that fails for files longer than 100 lines, for example).
> To avoid an obvious conflict of interest, I s
Eugene van der Pijll <[EMAIL PROTECTED]> writes:
> [EMAIL PROTECTED] schreef op 05 december 2001:
>> Please let me know when you think we should end the game.
>
> As soon as possible.
Afraid we're catching up?
Actually, I've about given up on trying to find the extra two strokes
to get level wit
to end this madness! :)
the leaderboard is full (more or less) and is perhaps scoreas are average and true...
well still anyone can post better solution(s) later :)
anyway it was fun and I'd like to thank you all!
good luck to the finalists!
P! Vladi.
ps: can anyone explain how (well, why!
IMO it is better to post everyone's solutions (regardless duplications)
it won't be big message (still there were longer ones I guess)...
well at least I'm curious :)
P! Vladi.
Eugene van der Pijll wrote:
>
> [EMAIL PROTECTED] schreef op 05 december 2001:
> > Given that tsanta.pl has many loo
On Wed, 05 Dec 2001 at 10:55:25 +, Piers Cawley wrote:
> Eugene van der Pijll <[EMAIL PROTECTED]> writes:
> > [EMAIL PROTECTED] schreef op 05 december 2001:
> >> Please let me know when you think we should end the game.
Well, 6 December is St Nicolas' day, so that sounds like a good time to
s
> ps: can anyone explain how (well, why!) the -p11..& tail works? :)
Despite of my poor golf-score (107), I understood this one...
perl -pe'11..&' is the same as:
while(<>){
11..&;
} continue {
print;
}
The .. must be understood as the flip-flop operator: eval first part until it
gets true,
Jérôme Quelin wrote:
>
> > ps: can anyone explain how (well, why!) the -p11..& tail works? :)
>
> Despite of my poor golf-score (107), I understood this one...
>
> perl -pe'11..&' is the same as:
> while(<>){
> 11..&;
> } continue {
> print;
> }
yep this is obvious
>
> The .. must be und
On Wed, Dec 05, 2001 at 02:17:40PM +0200, Vladi Belperchinov-Shabanski wrote:
> so it looks like it is undocumented really, isn't it?
>From L:
If either operand of scalar ".." is a
constant expression, that operand is implicitly compared
to the $. variable, the current lin
On Wed, Dec 05, 2001 at 12:57:01PM +0100, Jérôme Quelin wrote:
> But second part is a call to the 'Main::' subroutine, which does not exist:
> perl crashes.
Since no one pointed this error out, the call is actually "main::;"
which means you can fix it with a "*;=sub{exit};11..&"
I doubt this is
On Wed, Dec 05, 2001 at 02:17:40PM +0200, Vladi Belperchinov-Shabanski wrote:
> > The .. must be understood as the flip-flop operator: eval first part until it
> > gets true, then eval second part until it gets true.
>
> I've read flip-flop operator description in the camel book but...
>
> > W
ok I give up -- never used this and probably will never do...
thanx for the hint!
P! Vladi.
Robin Houston wrote:
>
> On Wed, Dec 05, 2001 at 02:17:40PM +0200, Vladi Belperchinov-Shabanski wrote:
> > so it looks like it is undocumented really, isn't it?
>
> >From L:
>
>If either op
On 5 Dec 2001, at 18:04, [EMAIL PROTECTED] wrote:
> Piers Cawley wrote:
> > I think the particular 'creative in the extreme' entry that Andrew was
> > referring to was my head.pl that printed 10 lines then crashed using:
> >
> > #!perl -p
> > 11..&
>
> Yes indeed. When I first saw that I
On 5 Dec 2001, at 11:34, [EMAIL PROTECTED] wrote:
> On Wed, Dec 05, 2001 at 05:11:43AM -0500, Michel Lambert wrote:
> > > defined $flag && !$flag
> > > So, who does better?
> >
> >
> > defined ($var = $flag) && !$var
> >
> > $flag is only evaluated once. :)
>
>
> But Bart said he wanted to t
On 5 Dec 2001, at 13:14, Vladi Belperchinov-Shabanski wrote:
> IMO it is better to post everyone's solutions (regardless duplications)
> it won't be big message (still there were longer ones I guess)...
Indeed. At about 100chars per entry, it wouldn't be a very long email message,
would it...
Piers writes:
> Brad Greenlee <[EMAIL PROTECTED]> writes:
>
> > What's really stumping me is that there has to be a shorter
> solution for
> > wc.pl (mine is 23), but I haven't been able to get past the
> need for printf
> > (at least, not for a shorter solution). Has anyone managed
> to do i
"Bernie Cosell" <[EMAIL PROTECTED]> writes:
> On 5 Dec 2001, at 18:04, [EMAIL PROTECTED] wrote:
>
>> Piers Cawley wrote:
>> > I think the particular 'creative in the extreme' entry that Andrew was
>> > referring to was my head.pl that printed 10 lines then crashed using:
>> >
>> > #!perl -p
>
Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> wrote:
> > When evaluating a test that is a single number, perl compares
> > with line number (ie, $.).
>
> which is strange! accordingly to this, the code (for example):
>
> while(<>){ print if 10; }
>
> should print 10th line only ($. ==
Jérôme Quelin <[EMAIL PROTECTED]> wrote:
> perl -pe'11..&' is the same as:
> while(<>){
> 11..&;
> } continue {
> print;
> }
>
[snip]
> But second part is a call to the 'Main::' subroutine,
> which does not exist: perl crashes.
You mean the main::; subroutine. The semicolon is interpreted
as
Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
> Those listed are for (un)readability, but the y yyyc example is
> the same as y///c.
Not for golf. For golf you have to use a punctuation character
as the delimiter to avoid extra space. For obfuscation, you
might try 'y ' or even 'y c
On Wed, Dec 05, 2001 at 04:57:48PM +1100, [EMAIL PROTECTED] wrote:
> The programs should be "sound"; passing tsanta.pl is no guarantee.
> A program that failed on files longer than 100 lines, for instance,
> would certainly be disqualified.
Urgh. Then you can s/2.1/2+.5/ my entries and in
On 5 Dec 2001, at 12:40, Piers Cawley wrote:
> "Bernie Cosell" <[EMAIL PROTECTED]> writes:
>
> > On 5 Dec 2001, at 18:04, [EMAIL PROTECTED] wrote:
> >
> >> Piers Cawley wrote:
> >> > I think the particular 'creative in the extreme' entry that Andrew was
> >> > referring to was my head.pl that pr
Bernie Cosell schreef op 05 december 2001:
> Meta-question: since Perl is content to try to *call* '&main::;' is there
> some trickery to *DEFINE* such a subroutine? For example, trying:
>main:: { die; }
> gets you what I would have expected in the '..&' case: a syntax error for a
> missing
Bernie Cosell <[EMAIL PROTECTED]> wrote:
> I realize that, but still it seems odd that the construct:
> &;
> actually calls a null-named subroutine rather than giving you a
> syntax error.
It's not a null-named subroutine. The semicolon is the sub
name. As you said later in your message,
On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
> Bernie Cosell schreef op 05 december 2001:
> > Meta-question: since Perl is content to try to *call* '&main::;' is there
> > some trickery to *DEFINE* such a subroutine? For example, trying:
> >main:: { die; }
> > gets you what I would h
Bernie Cosell <[EMAIL PROTECTED]> wrote:
> good heavens.. the actual subroutine name is semi-colon?? So
> the name isn't missing and isn't null, but is ';'. I'm not sure
> that that doesn't make it MORE confusing to me --- Are there
> other punctuation marks that work in that context??
perl
Bernie Cosell schreef op 05 december 2001:
> On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
>
> > Bernie Cosell schreef op 05 december 2001:
> > > Meta-question: since Perl is content to try to *call* '&main::;' is there
> > > some trickery to *DEFINE* such a subroutine? For example, tryin
"Bernie Cosell" <[EMAIL PROTECTED]> writes:
> On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
>
>> Bernie Cosell schreef op 05 december 2001:
>> > Meta-question: since Perl is content to try to *call* '&main::;' is there
>> > some trickery to *DEFINE* such a subroutine? For example, trying:
"Bernie Cosell" <[EMAIL PROTECTED]> writes:
> On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
>
>> Bernie Cosell schreef op 05 december 2001:
>> > Meta-question: since Perl is content to try to *call* '&main::;' is there
>> > some trickery to *DEFINE* such a subroutine? For example, trying:
On Wed, 5 Dec 2001 07:44:00 -0400, Bernie Cosell wrote:
>but from what he said, I'd think that bumming off of concluding "It is not
>undef and not true" implies "it must have been zero" is legit within the
>parameters of the challenge, no??
Yes. The values to test for are true, false (but not
On 5 Dec 2001, at 14:46, Eugene van der Pijll wrote:
> Bernie Cosell schreef op 05 december 2001:
> > On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
> > 2) WHY does perl allow this --- it still seems like a slam-dunk syntax error
> > situation to me
>
> The global variables @a, $a, %a an
En réponse à Piers Cawley <[EMAIL PROTECTED]>:
> "Bernie Cosell" <[EMAIL PROTECTED]> writes:
> > Three questions:
> > 1) is semicolon the ONLY puncuation mark that has this odd
> > special-dispensation?
>
> Hell no:
>
> perl -e '*{" "} = sub {42}; print &{" "}'
>
> I can't pretend that I *like
On 5 December 2001 13:41, Piers Cawley [mailto:[EMAIL PROTECTED]] wrote:
> "Bernie Cosell" <[EMAIL PROTECTED]> writes:
> > Three questions:
> > 1) is semicolon the ONLY puncuation mark that has this odd
> > special-dispensation?
>
> Hell no:
>
> perl -e '*{" "} = sub {42}; print &{" "}'
>
> I c
On 5 December 2001 14:29, BooK [mailto:[EMAIL PROTECTED]] wrote:
> En réponse à Piers Cawley <[EMAIL PROTECTED]>:
>
>
> > perl -e '*{" "} = sub {42}; print &{" "}'
> >
> > I can't pretend that I *like* this, but it has a certain
> cute insanity
> > to it.
>
> Since the symbol table is a hash
On Wed, Dec 05, 2001 at 08:37:49AM -0600, [EMAIL PROTECTED] wrote:
> On 5 December 2001 14:29, BooK [mailto:[EMAIL PROTECTED]] wrote:
> > En réponse à Piers Cawley <[EMAIL PROTECTED]>:
> >
> >
> > > perl -e '*{" "} = sub {42}; print &{" "}'
> > >
> > > I can't pretend that I *like* this, but i
On 5 December 2001 14:49, [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] wrote:
> On Wed, Dec 05, 2001 at 08:37:49AM -0600, [EMAIL PROTECTED] wrote:
> >
> > With fixes for Win2k's command shell, it does indeed work...
> >
> > perl -e "*{''} = sub {13}; print &{''}"
> >
> > The real question is of
Bernie writes:
> On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
>
> > Bernie Cosell schreef op 05 december 2001:
> > > Meta-question: since Perl is content to try to *call*
> '&main::;' is there
> > > some trickery to *DEFINE* such a subroutine? For example, trying:
> > >main:: { die
On Wed, Dec 05, 2001 at 10:05:16AM -0500, Ala Qumsieh wrote:
>
> Bernie writes:
> > On 5 Dec 2001, at 14:09, Eugene van der Pijll wrote:
> >
> > > Bernie Cosell schreef op 05 december 2001:
> > > > Meta-question: since Perl is content to try to *call*
> > '&main::;' is there
> > > > some tricke
On Wed, Dec 05, 2001 at 04:24:50PM +0100, [EMAIL PROTECTED] wrote:
> echo "Foo" | perl -nle '*;=sub{1};print&'
Looking at that, I can't but feel the need for an
obfuscated sepuku...
echo "Foo" | perl -nle '*;=sub{&;};&'
Joy,
`/anick
--
print map chr$_[0]-ord$_,@_='
On Wed, Dec 05, 2001 at 04:24:50PM +0100, [EMAIL PROTECTED] wrote:
> Yeah, but you know, one can leave out the final semi colon
>
> echo "Foo" | perl -nle '*;=sub{1};print&'
^ ^
and these quotes also ...
[EMAIL PROTECTED] ("Bernie Cosell") writes:
>On 5 Dec 2001, at 11:34, [EMAIL PROTECTED] wrote:
>> But Bart said he wanted to test for 0. The test above, and several of
>> the other proposals don't distinguish between 0 and the empty string.
Here's a trick: ~(~$flag||0) will map the false values u
How about
(eval{$flag} eq '0')
--
- - Martin "Kingpin" Thurn[EMAIL PROTECTED]
Research Software Engineer (703) 793-3700 x2651
The Information Refinery http://tir.tasc.com
Northrop Grumman IT TASC http://www.tasc.com
We get
On Dec 5, Keith C. Ivey said:
>Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
>
>> Those listed are for (un)readability, but the y yyyc example is
>> the same as y///c.
>
>Not for golf. For golf you have to use a punctuation character
>as the delimiter to avoid extra space. For obfuscation, yo
On Wed, Dec 05, 2001 at 11:44:30AM -0500, Martin 'Kingpin' Thurn wrote:
> How about
>
> (eval{$flag} eq '0')
That triggers a warning if $flag is undefined. If one doesn't care
about warnings, "$flag eq 0" would do too. However, it's doesn't
return true on "", which turned out to be required.
[EMAIL PROTECTED] () writes:
>On Wed, Dec 05, 2001 at 11:44:30AM -0500, Martin 'Kingpin' Thurn wrote:
>> How about
>>
>> (eval{$flag} eq '0')
>That triggers a warning if $flag is undefined. If one doesn't care
>about warnings, "$flag eq 0" would do too. However, it's doesn't
>return true on "",
Ian Phillipps wrote:
> Well, 6 December is St Nicolas' day, so that sounds like a good time to
> stop... give the diehards another 24 hours.
Thanks Ian! I needed a good excuse to stop the torture.
Santa the Arbiter hereby declares that the cut-off time for
entries is Thursday 6 December. But whic
On Thu, 6 Dec 2001 [EMAIL PROTECTED] wrote:
> In deference to the many Perl programmers living there,
> I choose Thursday, noon at Midway Island.
> --
> Thu noon Midway Island (GMT-11)
[snip]
> Fri 10:00 AMSolomon Islands
> Fri 11:00 AMAuckland
Do
Eugene van der Pijll wrote:
> Just post the entries of the top-5 to fwp, and let everyone comment,
> including the competitors.
You're right; it's the Perl way. I am sure the competitors can
agree among themselves. In the unlikely event of a dispute,
I can call in the independent experts for a de
[EMAIL PROTECTED] schreef op 06 december 2001:
> Eugene van der Pijll wrote:
> > Just post the entries of the top-5 to fwp, and let everyone comment,
> > including the competitors.
>
> You're right; it's the Perl way. I am sure the competitors can
> agree among themselves. In the unlikely event o
On Wed, 5 Dec 2001, Andy Bach wrote:
>
>
> Doesn't seem fair, you're giving the Aussies a whole extra day!!!
>
> a
>
Well, they need it ;)
*g,d&r*
Si.
Eugene van der Pijll <[EMAIL PROTECTED]> writes:
> [EMAIL PROTECTED] schreef op 06 december 2001:
>> Eugene van der Pijll wrote:
>> > Just post the entries of the top-5 to fwp, and let everyone comment,
>> > including the competitors.
>>
>> You're right; it's the Perl way. I am sure the competit
Piers writes:
> Best scores per hole would be really good. Sooner rather than later
> please.
I second that. This gives the rest of us a chance to catch up before the end
of the game!
--Ala
Quite a few leaderboard changes.
Piers has broken free of the brawling pack into second place.
Ronald has latched back onto Japhy (as predicted by Santa;-).
I am really enjoying this ding-dong battle between the two
early leaders!
Mysteriously, a new 'nameless' dark horse, [EMAIL PROTECTED],
has
On 06 Dec 01 at 11:09:22AM, [EMAIL PROTECTED] wrote:
>
> Mysteriously, a new 'nameless' dark horse, [EMAIL PROTECTED],
> has also emerged with a sensational opening bid of 92 strokes.
> And former English cricketing great, Ian Botham, has opened with
> a very tidy 96 strokes (our first celebrity
On 06 Dec 01 at 11:38:19AM, [EMAIL PROTECTED] wrote:
> s/t/re/;
Actually, I didn't intend this to be the only info given. In my mailer
I saw "Ian Boreham <[EMAIL PROTECTED]>", and thought, well, it's OK this
time.
Then when I got the mail from the list, I discovered that it had been
stripped out
Eugene van der Pijll wrote:
>Perhaps it would be best to begin a new thread for each of the problems.
>This is already the largest thread on fwp since I don't know when.
Yes.
Eugene van der Pijll wrote:
>I could post my scores for each hole a few hours before the deadline,
>if there is any intere
In article <[EMAIL PROTECTED]>,
Bart Lateur <[EMAIL PROTECTED]> wrote:
>I often use tri-state flags, with possible value true (1), false (0), or
>undetermined (undef).
>
>The question is: how do you test for one of the flags, in particular for
>0, without warnings?
Here's one way :)
use Data::Du
Tie-Breaking Rule
-
If 2 or more players are tied on a given score, the first
to post is the winner.
Current Leaderboard
---
1. 89Eugene van der Pijll
2. 91Piers Cawley
3. 91^ Rick Delaney
4. 92Rick Klement
5. 92
[EMAIL PROTECTED] schreef op 06 december 2001:
>
> "if there is any interest" ... hmm, Piers, do you give a damn?
> Eugene, I think there is intense interest in your scores!
I did get that impression.
> I would like to leave it up to Eugene to decide when/if he posts
> his scores. I will be sle
Now that Eugene has shown great sportsmanship in revealing
the lowest scores for each hole, I am free to reveal the
current hole leaders.
Significantly, Ronald J Kimball, Japhy and Rick Delaney all
won their holes on their first posts of the game, just hours
after it was announced! I think that s
> "BL" == Bart Lateur <[EMAIL PROTECTED]> writes:
BL> Yes. The values to test for are true, false (but not undef), and undef.
i have an unusual variant of that in stem. many calls return either an
object or an error string. so the main boolean test is ref! and in some
cases undef is a le
79 matches
Mail list logo