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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
Mark A. Biggar
May 20, 2005 09:07
Re: reduce metaoperator on an empty list
Message ID:
John Macdonald wrote:

> Is there a built-in operator that doesn't have a meaningful
> identity value?  I first thought of exponentiation, but it has
> an identity value of 1 - you just have to realize that since
> it is a right associative operator, the identity has to be
> applied from the right.

Well the identity of % is +inf (also right side only).  The identities 
for ~| and ~^ are infinitely long bitstrings of 0's, while that for ~& 
is a similarly long bitstring of 1's.  The chained comparison ops are 
weird as depending of which why you define the associativity (and thus 
which side's value you return when true) you get either a left side only 
or right side only Identity.  E.g. if X<Y is left associative and 
returns Y when true then it has a left side identity of -inf, etc.  But 
as I'm not sure if the chained ops are actually going to be defined 
defined in terms of the associativity of the binary op (the way false 
results propagates through messes things up), so that argument may not work.


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