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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
Edward Cherlin
June 8, 2005 23:46
Re: reduce metaoperator on an empty list
Message ID:
On Tuesday 07 June 2005 08:08, Larry Wall 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
> "". 

The table of Iverson's chosen identities in J is at
He uses _ for +Inf and __ for -Inf and does cover < and >.

> We can go as far as having -Inf on [<] and +Inf on [>], 
> but maybe that means we have to define values that are
> positive and negative infinity on strings so we can get [gt]
> and [lt] indentity values. Those might be useful in any event.

My Second System alarm is going off. What is the result of 
(-Inf)~(+Inf) or whatever the syntax would be? Or indeed 
(-Inf)~$String for any string? I know what it means to say that 
+Inf is the identity for a numeric min function, and -Inf for 
max, but an infinite string value baffles me. It would have to 
satisfy -Inf le "", right? But with no values in between?

When considering what extensions to make in APL and J, Iverson 
always asked what identities could be preserved at the 
boundaries. Thus if C is identical to A,B (APL catenation) with 
neither A nor B empty, then f/C is identical to (f/A)f(f/B). So 
using identity elements, we can extend this identity to some 
functions, and to arrays within their domains.

What identities did you have in mind for string infinities? What 
sort of reduction can you do on "Hello, "~(+Inf)~"world"? How 
does it print? What good is it at all?
Edward Cherlin
Generalist & activist--Linux, languages, literacy and more
"A knot! Oh, do let me help to undo it!"
--Alice in Wonderland

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About