From 5fc7589c863f06f1f71db8f9f9c5378c275c559d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 30 Nov 2014 17:25:58 -0500 Subject: math: Add modulo*. * sly/math.scm (modulo*): New procedure. --- sly/math.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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))) -- cgit v1.2.3