On Tuesday 07 June 2005 23:41, Luke Palmer wrote: > On 6/7/05, Larry Wall <larry@wall.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, PhilThread Previous | Thread Next