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

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
May 23, 2005 13:56
Re: reduce metaoperator on an empty list
Message ID:

There are actuall two usefull definition for %.  The first which Ada calls 'mod' always returns a value 0<=X<N and yes it has no working value that is an identity.  The other which Ada calls 'rem' defined as follows:

Signed integer division and remainder are defined by the relation: 

A = (A/B)*B + (A rem B)

   where (A rem B) has the sign of A and an absolute value less than the absolute value of B. Signed integer division satisfies the identity: 

(-A)/B = -(A/B) = A/(-B)

It does have a right side identity of +INF.

Mark Biggar

> HaloO Mark,
> please don't regard the following as obtrusive.
> you wrote:
> > 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;
> Or actually $n % any( abs($n)+1 .. Inf ) to really exclude 0
> from the junction.
> > $n % any (($n+1)..Inf),  $n % $n = 0. 
> That depends on the definition of % and the sign of $n.
> With the euclidean definition 0 <= ($n % $N == $n % -$N) < abs($N)
> and for $n < 0 there's no identity at all. The identity element
> has to be an element of the set, which +Inf isn't. It's a type.
> BTW, is % defined as truncation in Perl6?
> That would be a bit unfortunate. Simple but not well thought out.
> -- 
> TSa (Thomas SandlaƟ)

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