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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
mark.a.biggar
Date:
May 20, 2005 18:17
Subject:
Re: reduce metaoperator on an empty list
Message ID:
052020052214.26999.428E614200084E090000697722007507849D0E0909070DD20ED2059D0E03@comcast.net

> 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
mark@biggar.org
mark.a.biggar@comcast.net
mbiggar@paypal.com



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About