>>>>> "DC" == Damian Conway <[EMAIL PROTECTED]> writes:

>> And for the N case, it gets even uglier. So reduce should be able
>> to supply the next N-1 defined() values.

DC>     $def_sum = reduce { $_[0]+$_[1] } grep {defined} @numbers;

Fine. 

Even better if the optimizer could recognize the idiom and use the
reduce_no_undefs version.

Any problems if the reduce_no_undefs version were used for
the tristate pragma?

I'm not sure it should because we would be making the reduce operator
too smart. But I can see the issue that a single undef would turn the
results to undef.


While we are here, can reduce itself generate an average? I.e. something
cuter than:

        $avg = reduce { $_[0] + $_[1] } @numbers / @numbers;


<chaim>
-- 
Chaim Frenkel                                        Nonlinear Knowledge, Inc.
[EMAIL PROTECTED]                                               +1-718-236-0183

Reply via email to