Well, positiveRemainder should be renamed "mod".  Also, addmod, submod,
mulmod assume that their first two parameters are positive, which is an
unreasonable restriction.  For example:

(1) -> addmod(-13,0,10)

  (1)  - 13

(2) -> mulmod(-13,1,10)

  (2)  - 3

(3) -> submod(-13,0,10)

  (3)  - 3

(4) -> submod(0,13,10)

  (4)  -3

In fact, there should be two mod commands: x mod n, which produces a result
between 0 and n-1, and x bmod n (for "balanced mod") which produces a result
between -(n-1)/2 and (n-1)/2 if n is odd, and between -(n-2)/2 and n/2 if n
is even.

Looking through si.spad, it could easily be extended by

x mod y == MOD(x,y)$Lisp::INT

or some such.

cheers,
Alasdair

On 7/11/07, Bill Page <[EMAIL PROTECTED]> wrote:

On 7/10/07, Alasdair McAndrew wrote:
> Yes, that's pretty much what I did.  But surely such an important
function
> as mod should be available without having to write it yourself?
> ...

Digging a little deeper I found in the domain 'Integer':

(1) -> positiveRemainder(-13,10)

   (1)  7
                                                Type: PositiveInteger

I presume this is what you were looking for?

Also take a look at

(2) -> addmod(13,1,10)

   (2)  4
                                                 Type: PositiveInteger
(3) -> submod(13,1,10)

   (3)  12
                                                 Type: PositiveInteger
(4) -> mulmod(13,2,10)

   (4)  6
                                                 Type: PositiveInteger

Regards,
Bill Page.

_______________________________________________
Axiom-mail mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-mail

Reply via email to