Add 'positive?' and 'negative?' as primitives.
authorMark H Weaver <mhw@netris.org>
Tue, 28 Jan 2014 21:54:10 +0000 (16:54 -0500)
committerMark H Weaver <mhw@netris.org>
Tue, 28 Jan 2014 22:15:27 +0000 (17:15 -0500)
* module/language/tree-il/primitives.scm (*interesting-primitive-names*)
  (*effect-free-primitives*): Add 'positive?' and 'negative?'.
  (*primitive-expand-table*): Add primitive expanders for 'positive?'
  and 'negative?'.

module/language/tree-il/primitives.scm

index 15b5c44..f140eec 100644 (file)
@@ -35,7 +35,7 @@
 
 ;; When adding to this, be sure to update *multiply-valued-primitives*
 ;; if appropriate.
-(define *interesting-primitive-names* 
+(define *interesting-primitive-names*
   '(apply @apply
     call-with-values @call-with-values
     call-with-current-continuation @call-with-current-continuation
@@ -45,7 +45,7 @@
     values
     eq? eqv? equal?
     memq memv
-    = < > <= >= zero?
+    = < > <= >= zero? positive? negative?
     + * - / 1- 1+ quotient remainder modulo
     ash logand logior logxor lognot
     not
 (define *effect-free-primitives*
   `(values
     eq? eqv? equal?
-    = < > <= >= zero?
+    = < > <= >= zero? positive? negative?
     ash logand logior logxor lognot
     + * - / 1- 1+ quotient remainder modulo
     not
 (define-primitive-expander zero? (x)
   (= x 0))
 
+(define-primitive-expander positive? (x)
+  (> x 0))
+
+(define-primitive-expander negative? (x)
+  (< x 0))
+
 ;; FIXME: All the code that uses `const?' is redundant with `peval'.
 
 (define-primitive-expander +