ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: reduce metaoperator on an empty list
by Ph. Marek other posts by this author
Jun 7 2005 10:57PM messages near this date
Re: reduce metaoperator on an empty list | Re: reduce metaoperator on an empty list
On Tuesday 07 June 2005 23:41, Luke Palmer wrote:
>  On 6/7/05, Larry Wall <larry@[...].org> wrote:
>  > Okay, I've made up my mind.  The "err" option is not tenable because
>  > it can cloak real exceptions, and having multiple versions of reduce is
>  > simply multiplying entities without adding much power.  So let's allow
>  > an optional "identvalue" trait on operators.  If it's there, reduce
>  > can use it.  If it's not, reduce returns failure on 0 args.  Built-in
>  > addition will have an identity value of 0, while multiplication will
>  > have an identity value of 1.  String concatenation will have "".
>  > We can go as far as having -Inf on [<] and +Inf on [>]
> 
>  < and > still don't make sense as reduce operators.  Observe the table:
> 
>      # of args   |   Return (type)
>          0       |   -Inf
>          1       |   Num  (the argument)
>          2       |   bool
>          ...     |   bool
How about using initvalue twice for empty array, ie. always pad to at least 
two values?

So
 $bool = [<] @empty_array; # is false (-Inf < -Inf)
 $bool = [<=] @empty_array; # is true (-Inf <= -Inf)

Which would make some sort of sense - in an empty array there's no right 
element that's bigger than it's left neighbour ...

And if the case [<] @empty_array should return true it's easy to use ?? ::.


Just my ¤0.02.


Regards,

Phil

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved