exposing the functions in kernel

This commit is contained in:
Danny Yoo 2011-06-27 15:06:36 -04:00
parent fa49306546
commit 48f8acf121
4 changed files with 62 additions and 40 deletions

View File

@ -616,6 +616,7 @@ if (typeof(exports) !== 'undefined') {
// tan: scheme-number -> scheme-number
var tan = function(n) {
if (eqv(n, 0)) { return 0; }
if (typeof(n) === 'number') {
return FloatPoint.makeInstance(Math.tan(n));
}
@ -624,6 +625,7 @@ if (typeof(exports) !== 'undefined') {
// atan: scheme-number -> scheme-number
var atan = function(n) {
if (eqv(n, 0)) { return 0; }
if (typeof(n) === 'number') {
return FloatPoint.makeInstance(Math.atan(n));
}
@ -659,6 +661,7 @@ if (typeof(exports) !== 'undefined') {
// asin: scheme-number -> scheme-number
var asin = function(n) {
if (eqv(n, 0)) { return 0; }
if (typeof(n) === 'number') {
return FloatPoint.makeInstance(Math.asin(n));
}
@ -806,7 +809,7 @@ if (typeof(exports) !== 'undefined') {
var makeComplexPolar = function(r, theta) {
// special case: if theta is zero, just return
// the scalar.
if (equals(theta, 0)) {
if (eqv(theta, 0)) {
return r;
}
return Complex.makeInstance(multiply(r, cos(theta)),

View File

@ -1535,7 +1535,7 @@
MACHINE.env[MACHINE.env.length - 1],
0,
'exact?');
return jsnums.isExact(x);
return jsnums.isExact(MACHINE.env[MACHINE.env.length - 1]);
});
@ -1872,11 +1872,11 @@
1,
function(MACHINE) {
testArgument(MACHINE,
'integer',
'string',
isString,
MACHINE.env[MACHINE.env.length-1],
0,
'number->string');
'string->number');
return jsnums.fromString(MACHINE.env[MACHINE.env.length-1].toString());
});

View File

@ -1,5 +1,6 @@
#lang racket/base
(require (prefix-in math: (only-in racket/math pi sinh))
(require (prefix-in racket: (only-in racket/math pi sinh cosh sqr
sgn conjugate))
(prefix-in racket: racket/base)
racket/local
(for-syntax racket/base))
@ -9,7 +10,7 @@
;; constants
(define constant:true #t)
(define constant:false #f)
(define constant:pi math:pi)
(define constant:pi racket:pi)
(define constant:e (racket:exp 1))
@ -198,42 +199,46 @@
;; exn:fail:contract:arity?
;; exn:fail:contract:variable?
;; exn:fail:contract:divide-by-zero?
;; abs
;; quotient
;; remainder
;; modulo
abs
quotient
remainder
modulo
;; max
;; min
;; gcd
;; lcm
;; floor
;; ceiling
;; round
;; truncate
;; numerator
;; denominator
;; expt
;; exp
;; log
;; sin
;; cos
;; tan
;; asin
;; acos
;; atan
;; sqrt
;; integer-sqrt
;; make-rectangular
;; make-polar
;; real-part
;; imag-part
;; angle
;; magnitude
;; inexact->exact
gcd
lcm
floor
ceiling
round
truncate
numerator
denominator
expt
exp
log
sin
sinh
cos
cosh
tan
asin
acos
atan
sqr
sqrt
integer-sqrt
sgn
make-rectangular
make-polar
real-part
imag-part
angle
magnitude
conjugate
;; inexact->exact
;; exact->inexact
;; number->string
;; string->number
number->string
string->number
;; procedure?
pair?
;; (undefined? -undefined?)
@ -253,7 +258,7 @@
;; real?
;; rational?
;; integer?
;; exact?
exact?
;; inexact?
;; odd?
;; even?

View File

@ -610,6 +610,20 @@ EOF
(test '(displayln (sqrt 4))
"2\n")
(test '(displayln (integer-sqrt 4))
"2\n")
(test '(displayln (sgn 3))
"1\n")
(test '(displayln (number->string 42))
"42\n")
(test '(displayln (string->number "42"))
"42\n")
;; Knuth's Man-or-boy-test.