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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
May 20, 2005 18:17
Re: reduce metaoperator on an empty list
Message ID:

> Mark A. Biggar wrote:
> > Well the identity of % is +inf (also right side only).
> I read $n % any( $n..Inf ) == $n. The point is there's no
> unique right identity and thus (Num,%) disqualifies for a
> Monoid. BTW, the above is a nice example where a junction
> needn't be preserved :)

If as usual the definition of a right identity value e is that a op e = a for all a,
then only +inf works.  Besdies you example should have been;
$n % any (($n+1)..Inf),  $n % $n = 0. 

> > E.g. if X<Y is left associative and  returns Y when true then ...
> Sorry, is it the case that $x = $y < $z might put something else
> but 0 or 1 into $x depending on the order relation between $y and $z?

Which is one reason why I siad that it might not make sense to define the chaining ops in terms of the associtivity of the binary ops,  But as we are interested in what [<] over the empty list shoud return , the identity (left or right) of '<' is unimportant as I think that should return false as there is nothing to be less then anything else.  Note that defaulting to undef therefore works in that case.

Mark Biggar

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