From 057f6ca992401ed64bdf9e05dec8448603198977 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 23 Apr 2018 23:15:45 -0700 Subject: [PATCH] Move int:modulo to primitive-arithmetic and export it. --- src/runtime/arith.scm | 9 --------- src/runtime/primitive-arithmetic.scm | 11 ++++++++++- src/runtime/runtime.pkg | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) 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? -- 2.25.1