[racket] Modular arithmetic
2012/12/20 Erich Rast <erich at snafu.de>:
> Hi,
>
> For compatibility I need modular arithmetic for some
> standard numeric types such as signed 64bit integer, unsigned 64bit
> integer, signed 32 bit integer, and so on. Preferably it shouldn't be
> very slow.
>
> What's the best way to get this? Is there a package for this already?
For general modular arithmetic, you can do this using
a daily build:
#lang racket
(require math)
(with-modulus 5
(list
(mod 7)
(mod+ 3 3)
(mod* 3 7)
(modexpt 3 2)))
The output is:
'(2 1 1 4)
See documentation here:
http://pre.racket-lang.org/docs/html/math/number-theory.html?q=math#(part._congruences)
--
Jens Axel Søgaard