whalesong/js-assembler/runtime-src/baselib-numbers.js
2011-07-06 16:49:28 -04:00

48 lines
1.1 KiB
JavaScript

// Numbers.
(function(baselib) {
var exports = {};
baselib.numbers = exports;
var isNumber = jsnums.isSchemeNumber;
var isReal = jsnums.isReal;
var isRational = jsnums.isRational;
var isComplex = isNumber;
var isInteger = jsnums.isInteger;
var isNatural = function(x) {
return (jsnums.isExact(x) && isInteger(x)
&& jsnums.greaterThanOrEqual(x, 0));
};
var isNonNegativeReal = function(x) {
return isReal(x) && jsnums.greaterThanOrEqual(x, 0);
};
//////////////////////////////////////////////////////////////////////
// Exports
// We first re-export everything in jsnums.
for (var prop in jsnums) {
if (jsnums.hasOwnProperty(prop)) {
exports[prop] = jsnums[prop];
}
}
exports.isNumber = jsnums.isSchemeNumber;
exports.isReal = isReal;
exports.isRational = isRational;
exports.isComplex = isComplex;
exports.isInteger = isInteger;
exports.isNatural = isNatural;
exports.isNonNegativeReal = isNonNegativeReal;
})(this['plt'].baselib);