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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
John Macdonald
May 24, 2005 06:42
Re: reduce metaoperator on an empty list
Message ID:
On Fri, May 20, 2005 at 10:14:26PM +0000, wrote:
> > 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.

The identity operand is -inf for < and <=, and +inf for >
and >=.  A chained relation < (>, <=, >=) is then taken to
mean monotonically increasing (decreasing, non-decreasing,
non-increasing), and an empty list, like a one element list,
is always in order.


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