in reply to Re: (Golf) Warningless Comparison
in thread (Golf) Warningless Comparison
I didn't attempt to cater for your test ii because it was not part of the original specs. tadman said.
As a note, the 'new' value is always present, even if it is undef.
If I remove all whitespace and newlines, redundant ;'s etc from my solution above it comes out to 87
sub f{local($^W,$a)=(0,pop);grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a-> +{$_}{C}}keys%$a} #87
Then I noticed that I could save a couple more whilst still retaining a 'safe' function (ie. doesn't stomp on any globals) by switch to mying $a for 85
sub g{local$^W=0;my$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a->{$ +_}{C}}keys%$a} #85
but I go the whole hog and abandon safety completely, this can be reduced further (and neatly, below the traditional 80 char line) to 78....
sub h{$^W=0;$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a->{$_}{C}}k +eys%$a} #78
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: (Golf) Warningless Comparison
by demerphq (Chancellor) on Sep 29, 2002 at 20:02 UTC | |
Hmm, my apologies, I seem to be a bit myopic tonight. I didnt notice that comment. So tadmans solution pases under the rule change. Still under my test scenario (the 'ii' case removed) all of your solutions generate warnings and fail. Sorry.
--- | [reply] [d/l] |
by BrowserUk (Patriarch) on Sep 29, 2002 at 20:18 UTC | |
And here's what you get if you comment out your signal handler. NOTE: NO WARNINGS from my original entry. I hade to comment out your implementation of tadman's solution because if wouldn't compile. I think the problem lies in your signal handler rather than my code. I specifically disable the warnings where I accept they will occur using the standard Perl mechanism of local $^W=0; Your signal handler converts a SIG_WARN into a SIG_INT (die) which kind of belies the reasons for Perl distinguishing between them. If you change the rules of Formula 1 to have a mandatory water section and then enter in a D.U.K.W., you'll likely win every race.
Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring! | [reply] [d/l] |
by demerphq (Chancellor) on Sep 29, 2002 at 20:35 UTC | |
Nope. Did you look at what was on line 22? I hade to comment out your implementation of tadman's solution because if wouldn't compile. Weird, it compiles here. Are you sure it didnt get screwed on download or something? Your signal handler converts a SIG_WARN into a SIG_INT (die) which kind of belies the reasons for Perl distinguishing between them. This has nothing to do with why your code generates warnings when you think it shouldnt. Let this whole thing be a lesson to you: -w and $^W should as the documentation says be avoided!
--- demerphq | [reply] [d/l] |