summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-11-30 17:25:58 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-11-30 17:25:58 -0500
commit5fc7589c863f06f1f71db8f9f9c5378c275c559d (patch)
treef4630508d6ea58df3624121d5bd880783cb62cdf
parent23d628e4d6692f4e9636e1eb380d80dfda2acad9 (diff)
math: Add modulo*.
* sly/math.scm (modulo*): New procedure.
-rw-r--r--sly/math.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/sly/math.scm b/sly/math.scm
index 923a93d..90545ac 100644
--- a/sly/math.scm
+++ b/sly/math.scm
@@ -34,7 +34,8 @@
clamp
linear-scale
half square
- make-lerp lerp))
+ make-lerp lerp
+ modulo*))
;; Dave was editing this module on Pi Approximation Day.
;;
@@ -122,3 +123,8 @@ range [0, 1]."
(* b alpha))))
(define lerp (make-lerp + *))
+
+(define (modulo* x y)
+ "Return the remainder of X / Y. X and Y may be exact integers,
+rational numbers, or inexact numbers."
+ (- x (* (floor (/ x y)) y)))