14 lines
391 B
Plaintext
14 lines
391 B
Plaintext
|
;; In Emacs, open this file in -*- Scheme -*- mode
|
||
|
|
||
|
;; Test the "letrec" expression
|
||
|
|
||
|
(@byte-write 66)
|
||
|
|
||
|
(letrec ((fact (fun (x) (if (@= 0 x) 1 (@* x (fact (@- x 1)))))))
|
||
|
(@byte-write (@- (fact 5) 55)))
|
||
|
(letrec ((even? (fun (x) (if (@= x 0) #t (odd? (@- x 1)))))
|
||
|
(odd? (fun (x) (if (@= x 0) #f (even? (@- x 1))))))
|
||
|
(if (even? 66)
|
||
|
(@byte-write 66)
|
||
|
(@byte-write 63)))
|