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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
From:
John Macdonald
Date:
May 24, 2005 06:42
Subject:
Re: reduce metaoperator on an empty list
Message ID:
20050524134632.GA20817@lupus.perlwolf.com
On Fri, May 20, 2005 at 10:14:26PM +0000, mark.a.biggar@comcast.net 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


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