...
Code Block |
---|
; A natural (N) is either: ; - 0 ; - (add1 n) ; where n is a natural ; Template ; nat-f : natural -> ... ;(define (f ... n ... ) ; (cond [(zero? n) ...] ; [(positive? n) ; ... (f ... (sub1 n) ... ) ...])) |
...
Code Block |
---|
;; Given (define-struct add (m n)) (define-struct sub (m n)) (define-struct mul (m n)) (define-struct div (m n)) ;; an Arithmetic-Expression (AExp) is either: ;; - a number ; ;; - (make-add m n) where m,n are AExps; ;; - (make-sub m n where m,n are AExps; ;; - (make-mul m n where m,n are AExps; or ;; - (make-div m n where m,n are AExps, |
...