首页 > 代码库 > Practice2

Practice2

Structure and Interpretation of Computer Programs

1.11

 1 (define (func n) 2   (cond 3     ((< n 3) n) 4     ((>= n 3) (+ (* 3 (func (- n 3))) (* 2 (func (- n 2))) (func (- n 1)))) 5     ) 6   ) 7  8  9  (define (func1 n)10    (sub 2 1 0 n))11 12 (define (sub a b c n)13   (cond ((= n 0) c)14         ((= n 1) b)15         ((= n 2) a)16         (else (sub (+ (* c 3) (* b 2) a) a b (- n 1)))17         )18   )

 

Practice2