positive and negative predicates

This commit is contained in:
Danny Yoo 2011-09-01 11:42:48 -04:00
parent 48e9bbc518
commit d2a0a17056
4 changed files with 51 additions and 3 deletions

View File

@ -1298,6 +1298,24 @@
});
installPrimitiveProcedure(
'positive?',
1,
function(MACHINE) {
var n = checkReal(MACHINE, 'positive?', 0);
return baselib.numbers.greaterThan(n, 0);
});
installPrimitiveProcedure(
'negative?',
1,
function(MACHINE) {
var n = checkReal(MACHINE, 'negative?', 0);
return baselib.numbers.lessThan(n, 0);
});

View File

@ -315,8 +315,8 @@ exact-nonnegative-integer?
odd?
even?
zero?
;; positive?
;; negative?
positive?
negative?
;; box?
;; hash?

View File

@ -15,3 +15,17 @@ false
1
3
3
false
false
true
false
false
true
true
false
false
true
true
false
false
true

View File

@ -19,4 +19,20 @@
(min 3 4 5 6)
(min 3 1 4 1 5 9 2 6)
(min 3 20)
(min 20 3)
(min 20 3)
(positive? 0)
(negative? 0)
(positive? 42)
(negative? 42)
(positive? -42)
(negative? -42)
(positive? 3.1415926)
(negative? 3.1415926)
(positive? -3.1415926)
(negative? -3.1415926)
(positive? (expt 2 100))
(negative? (expt 2 100))
(positive? (expt -2 91))
(negative? (expt -2 91))