> >  $sum = @numbers ? reduce ^_+^_, @numbers : 0;
   > 
   > Although we're back to the pain of what happens when @numbers is
   > really fn().  This is unsatisfactorily nonidempotent (aliapotent? :-)
   > 
   >     $sum = fn() ? reduce ^_+^_, fn() : 0;

It would seem likely that most would trade space for time and avoid the
second call to fn() with:

        my @values = fn();
        $sum = @values ? reduce ^_+^_, @values : 0;

In any case, the preferred option should be to provide a default value:

        $sum = reduce ^_+^_, 0, @values;

which is always cleaner *and* shorter. :-)

Damian

Reply via email to