looking at tail behavior.

This commit is contained in:
Danny Yoo 2011-03-08 03:19:16 -05:00
parent 2b56c90c2c
commit 67e91a7212
2 changed files with 8 additions and 5 deletions

View File

@ -31,5 +31,6 @@
(provide lookup-primitive)
(define lookup-primitive (make-lookup #:functions (+ - * / = < <= > >= cons list car cdr
sub1
display newline displayln)
#:constants (null pi e)))

View File

@ -54,7 +54,9 @@
[steps 0])
(when debug?
(when (can-step? m)
(printf "~s\n" (current-instruction m))))
(printf "env-depth=~s instruction=~s\n"
(length (machine-env m))
(current-instruction m))))
(cond
[(can-step? m)
(loop (step m) (add1 steps))]
@ -158,25 +160,25 @@
(test (begin (define (f x)
(if (= x 0)
1
(* f (sub1 x))))
(* x (f (sub1 x)))))
(f 0))
1)
(test (begin (define (f x)
(if (= x 0)
1
(* f (sub1 x))))
(* x (f (sub1 x)))))
(f 1))
1)
(test (begin (define (f x)
(if (= x 0)
1
(* f (sub1 x))))
(* x (f (sub1 x)))))
(f 2))
2)
(test (begin (define (f x)
(if (= x 0)
1
(* f (sub1 x))))
(* x (f (sub1 x)))))
(f 3))
6)