14 lines
391 B
Plaintext
Raw Normal View History

2022-04-07 18:33:05 +02:00
;; 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)))