摘要: f(n) = n; n=3递归1 ;; Scheme code2 (define (foo1 n)3 (cond4 ((< n 3) n)5 (else (+6 (foo1 (- n 1))7 (* 2 (foo1 (- n 2)))8 (* 3 (foo1 (- n 3)))))))迭代 1 ;; Scheme code 2 (define (foo2 n) 3 (local ((define (f a b c counter) 4 (cond 5 (... 阅读全文
posted @ 2013-07-18 21:24 maxima 阅读(325) 评论(0) 推荐(0) 编辑
摘要: ;;预备函数(define (atom? x) (and (not (pair? x)) (not (null? x))))(define (sub1 x) (- x 1))(define (add1 x) (+ x 1));辅助函数,方便用来显示结果(define-syntax print (syntax-rules () ((_) #f) ((_ e) (begin (display 'e) (display " => ") (display e) (newlin... 阅读全文
posted @ 2013-07-18 21:23 maxima 阅读(367) 评论(0) 推荐(0) 编辑