develooper Front page | perl.perl6.language | Postings from May 2005

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
Damian Conway
Date:
May 31, 2005 18:00
Subject:
Re: reduce metaoperator on an empty list
Message ID:
429D0896.4070407@conway.org
Dave Whipp wrote:

> Damian Conway wrote:
> 
>>     0 args:  fail (i.e. thrown or unthrown exception depending on use 
>> fatal)
> 
> ...
> 
>>
>>     $sum  = ([+] @values err 0);
>>     $prod = ([*] @values err 1);
>>     $prob = ([*] @probs  err 0);
> 
> 
> Just wanted to check, if I've said "use fatal": will that "err 0" DWIM,

That depends what you mean. ;-)
Under "use fatal" you'll get an exception if you don't provide any args.


> or will the fatalness win?

The fatalness will win.


> Would I need to write

Yes. :-)

And what you'd need to write would be:

     $sum  = (try{ [+] @values } err 0);

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About