From c6f1aaf9419bd6dd32371189ba349672b44d0b7d Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Mon, 7 Mar 2011 21:51:55 -0500 Subject: [PATCH] recursion isn't working yet --- test-compiler.rkt | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test-compiler.rkt b/test-compiler.rkt index f352343..5e38f78 100644 --- a/test-compiler.rkt +++ b/test-compiler.rkt @@ -114,6 +114,49 @@ ;; And this should fail because it's not a lambda (test/exn (not-a-procedure 5)) +;; Square +(test (begin (define (f x) + (* x x)) + (f 3)) + 9) + +;; composition of square +(test (begin (define (f x) + (* x x)) + (f (f 3))) + 81) + + +; factorial +(test (begin (define (f x) + (if (= x 0) + 1 + (* f (sub1 x)))) + (f 0)) + 1) +(test (begin (define (f x) + (if (= x 0) + 1 + (* f (sub1 x)))) + (f 1)) + 1) +(test (begin (define (f x) + (if (= x 0) + 1 + (* f (sub1 x)))) + (f 2)) + 2) +(test (begin (define (f x) + (if (= x 0) + 1 + (* f (sub1 x)))) + (f 3)) + 6) + + + + + ;(simulate (compile (parse '42) 'val 'next))