Commit c4848f9d authored by Dan Holtby's avatar Dan Holtby
Browse files

add mutually recursive tests

parent c4eeaa51
......@@ -8,3 +8,11 @@
[else (+ (first lst) (f (rest lst)))]))
(f (list 1 2 3))
(define/trace (h n)
(if (zero? n) 0 (g (sub1 n))))
(define/trace (g n)
(if (zero? n) 0 (h (sub1 n))))
(h 3)
\ No newline at end of file
......@@ -8,3 +8,15 @@
(cond [(empty? lst) 0]
[else (g (first lst) (f (rest lst)))])))
(f (list 1 2 3))
(define (mutual n)
(local [(define/trace (f n)
(if (zero? n) 0 (g (sub1 n))))
(define/trace (g n)
(if (zero? n) 0 (f (sub1 n))))]
(f n)))
(mutual 3)
\ No newline at end of file
......@@ -17,6 +17,12 @@
< 5
<6
6
>(h 3)
>(g 2)
>(h 1)
>(g 0)
<0
0
EXPECTED
)
......@@ -38,6 +44,12 @@ EXPECTED
>(g 1 5)
<6
6
>(f 3)
>(g 2)
>(f 1)
>(g 0)
<0
0
EXPECTED
)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment