looking at tail behavior.
This commit is contained in:
parent
2b56c90c2c
commit
67e91a7212
|
@ -31,5 +31,6 @@
|
||||||
|
|
||||||
(provide lookup-primitive)
|
(provide lookup-primitive)
|
||||||
(define lookup-primitive (make-lookup #:functions (+ - * / = < <= > >= cons list car cdr
|
(define lookup-primitive (make-lookup #:functions (+ - * / = < <= > >= cons list car cdr
|
||||||
|
sub1
|
||||||
display newline displayln)
|
display newline displayln)
|
||||||
#:constants (null pi e)))
|
#:constants (null pi e)))
|
||||||
|
|
|
@ -54,7 +54,9 @@
|
||||||
[steps 0])
|
[steps 0])
|
||||||
(when debug?
|
(when debug?
|
||||||
(when (can-step? m)
|
(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
|
(cond
|
||||||
[(can-step? m)
|
[(can-step? m)
|
||||||
(loop (step m) (add1 steps))]
|
(loop (step m) (add1 steps))]
|
||||||
|
@ -158,25 +160,25 @@
|
||||||
(test (begin (define (f x)
|
(test (begin (define (f x)
|
||||||
(if (= x 0)
|
(if (= x 0)
|
||||||
1
|
1
|
||||||
(* f (sub1 x))))
|
(* x (f (sub1 x)))))
|
||||||
(f 0))
|
(f 0))
|
||||||
1)
|
1)
|
||||||
(test (begin (define (f x)
|
(test (begin (define (f x)
|
||||||
(if (= x 0)
|
(if (= x 0)
|
||||||
1
|
1
|
||||||
(* f (sub1 x))))
|
(* x (f (sub1 x)))))
|
||||||
(f 1))
|
(f 1))
|
||||||
1)
|
1)
|
||||||
(test (begin (define (f x)
|
(test (begin (define (f x)
|
||||||
(if (= x 0)
|
(if (= x 0)
|
||||||
1
|
1
|
||||||
(* f (sub1 x))))
|
(* x (f (sub1 x)))))
|
||||||
(f 2))
|
(f 2))
|
||||||
2)
|
2)
|
||||||
(test (begin (define (f x)
|
(test (begin (define (f x)
|
||||||
(if (= x 0)
|
(if (= x 0)
|
||||||
1
|
1
|
||||||
(* f (sub1 x))))
|
(* x (f (sub1 x)))))
|
||||||
(f 3))
|
(f 3))
|
||||||
6)
|
6)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user