[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 undef and ''
into 4294967295 (as well as the string "�"). It will pass both numeric
0 and "0" through, however.

>Well, what I thought he actually said was that the flag had one of
>the values 1,0,undef.

In that case, ! ~(~$flag||0) is what he needs.

>I suppose you could then consider it a quinary flag with two other
>hidden/illegal values: true but not 1, and false but not-numeric-zero
>and so in the '0' have to actually test for "was it really ZERO"
>rather than the flas- but-not-numeric-zero case.

The test above will yield false for '' and true for "0".

>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??

That must be for Bart to decide.

Lars Mathiesen (U of Copenhagen CS Dep) <[EMAIL PROTECTED]> (Humour NOT marked)

Reply via email to