diff --git a/assemble.rkt b/assemble.rkt index 910fa2b..03974dc 100644 --- a/assemble.rkt +++ b/assemble.rkt @@ -281,7 +281,7 @@ EOF [(boolean? val) (if val "true" "false")] [(empty? val) - (format "undefined")] + (format "Primitives.NULL")] [else (format "~s" val)]))) diff --git a/browser-evaluate.rkt b/browser-evaluate.rkt index b7e6856..fa2c2de 100644 --- a/browser-evaluate.rkt +++ b/browser-evaluate.rkt @@ -210,7 +210,9 @@ function createXMLHTTPObject() { var comet = function() { sendRequest("/eval", function(req) { - console.log(req.responseText); + // debug: + if (console && typeof(console.log) === 'function') { console.log(req.responseText); } + var invoke = eval(req.responseText)(); var output = []; var startTime, endTime; diff --git a/test-compiler.rkt b/test-compiler.rkt index cc57c3f..248eece 100644 --- a/test-compiler.rkt +++ b/test-compiler.rkt @@ -462,10 +462,26 @@ (test (begin (define (sum-integers a b) (if (> a b) 0 - (+ a (sum-integers (+ a 1) b)))) + (+ a (sum-integers (+ a 1) b)))) (sum-integers 1 100)) (* 50 101)) +(test (begin (define (sum term a next b) + (if (> a b) + 0 + (+ (term a) + (sum term (next a) next b)))) + (define (inc n) (+ n 1)) + (define (identity x) x) + (define (cube x) (* x x x)) + (define (sum-cubes a b) (sum cube a inc b)) + (define (sum-integers a b) (sum identity a inc b)) + + (list (sum-cubes 1 10) + (sum-integers 1 10))) + (list 3025 55)) + + ;(simulate (compile (parse '42) 'val 'next)) ;(compile (parse '(+ 3 4)) 'val 'next) \ No newline at end of file