Thanks all for the comments.

Indeed I am interested in the empty list, not the print statement.
I merely wanted to know if some sort special list operator existed.

I am pretty sure that the code with 'last' is quicker than the ones with 
'grep' but will do some tests on it.

Cheers,

Jeroen

>===== Original Message From "R. Joseph Newton" <[EMAIL PROTECTED]> =====
>"Scott R. Godin" wrote:
>
>> > #!/usr/bin/perl -w
>> >
>> > use strict;
>> >
>> > my @array = ('', 0, "", 1);
>> >
>> > my $hasTruth;
>> > foreach (@array) {
>> >   if ($_ ){
>> >     $hasTruth = "yezzindeedydo!";
>> >     last;
>> >   }
>> > }
>> > if ($hasTruth) {print "$hasTruth has truth\n";}
>> > else {print "Does not have truth";}
>> >
>> >
>> > Joseph
>>
>> #!/usr/bin/perl
>> use warnings;
>> use strict;
>>
>> my @array = ('', 0, "", 1);
>>
>> foreach (@array) {
>>         print $_ ? "$_ has truth\n" : "$_ has no truth\n;
>> }
>
>The problem is that you kept the bsth water and through out the baby.  The 
original poster was interested only in empty lists.  The print statements at 
the end of my code were only debug code to indicate the value assigned to the 
variable $hasTruth, which was the payload.
>
>The design, which may have seemed heavy to you, served a purpose by providing 
shortcut evaluation on failure--finding a true element in the list.  Since you 
can never make a shortcut evaluation in  affirming a categorical [this list 
has no valid elements, this list is all valid elements] the appropriate 
efficiency is to shortcut out on negation.
>
>Joseph
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to