Add GUARANTEEs for positive, negative, non-positive, and non-negative numbers.
authorJoe Marshall <eval.apply@gmail.com>
Wed, 9 Mar 2011 18:27:42 +0000 (10:27 -0800)
committerJoe Marshall <eval.apply@gmail.com>
Wed, 9 Mar 2011 18:27:42 +0000 (10:27 -0800)
src/runtime/arith.scm
src/runtime/runtime.pkg

index 37d10503302eaed1ba7910792274a92e1eab520b..da78fef88a658204cfbfbe55758b744fb1a744bf 100644 (file)
@@ -1846,6 +1846,17 @@ USA.
 (define-guarantee exact-nonnegative-integer "exact non-negative integer")
 (define-guarantee exact-positive-integer "exact positive integer")
 
+(define (non-negative? object)
+  (not (negative? object)))
+
+(define (non-positive? object)
+  (not (positive? object)))
+
+(define-guarantee positive "positive number")
+(define-guarantee negative "negative number")
+(define-guarantee non-positive "non-positive number")
+(define-guarantee non-negative "non-negative number")
+
 ;;; The following three procedures were originally just renamings of
 ;;; their COMPLEX: equivalents.  They have been rewritten this way to
 ;;; cause the compiler to generate better code for them.
index 3537ad6fd1225f747c1517d232c736361af8a925..9b5525cfbb0daa256c4911a57a78fa45fa9f0043 100644 (file)
@@ -2874,7 +2874,11 @@ USA.
          error:not-exact-rational
          error:not-inexact
          error:not-integer
+         error:not-negative
+         error:not-non-negative
+         error:not-non-positive
          error:not-number
+         error:not-positive
          error:not-rational
          error:not-real
          exact-nonnegative-integer?
@@ -2895,7 +2899,11 @@ USA.
          guarantee-exact-rational
          guarantee-inexact
          guarantee-integer
+         guarantee-negative
+         guarantee-non-negative
+         guarantee-non-positive
          guarantee-number
+         guarantee-positive
          guarantee-rational
          guarantee-real
          inexact?
@@ -2906,6 +2914,8 @@ USA.
          max
          min
          modulo
+         non-negative?
+         non-positive?
          number->string
          odd?
          quotient