From: Chris Hanson Date: Tue, 24 Apr 2018 06:15:45 +0000 (-0700) Subject: Move int:modulo to primitive-arithmetic and export it. X-Git-Tag: mit-scheme-pucked-x11-0.3.1~7^2~116 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=057f6ca992401ed64bdf9e05dec8448603198977;p=mit-scheme.git Move int:modulo to primitive-arithmetic and export it. --- diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index 7cdae3b8e..01dd548d9 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -260,15 +260,6 @@ USA. (define (int:even? n) (int:zero? (int:remainder n 2))) -(define (int:modulo n d) - (let ((r (int:remainder n d))) - (if (or (int:zero? r) - (if (int:negative? n) - (int:negative? d) - (not (int:negative? d)))) - r - (int:+ r d)))) - (define (int:gcd n m) (let loop ((n n) (m m)) (cond ((not (int:zero? m)) (loop m (int:remainder n m))) diff --git a/src/runtime/primitive-arithmetic.scm b/src/runtime/primitive-arithmetic.scm index 7f07d52c8..971beef6a 100644 --- a/src/runtime/primitive-arithmetic.scm +++ b/src/runtime/primitive-arithmetic.scm @@ -274,4 +274,13 @@ USA. (int:remainder integer-remainder 2)) (define-integrable (int:<= n m) (not (int:> n m))) -(define-integrable (int:>= n m) (not (int:< n m))) \ No newline at end of file +(define-integrable (int:>= n m) (not (int:< n m))) + +(define (int:modulo n d) + (let ((r (int:remainder n d))) + (if (or (int:zero? r) + (if (int:negative? n) + (int:negative? d) + (not (int:negative? d)))) + r + (int:+ r d)))) \ No newline at end of file diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 7927be55b..836a03e15 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -344,6 +344,7 @@ USA. int:>= int:divide int:integer? + int:modulo int:negate int:negative? int:positive?