- 博客(5)
- 收藏
- 关注
转载 递归和迭代计算过程
f(n) = n; n<3f(n) = f(n-1) + 2*f(n-2) + 3*f(n-3); n>=3递归1 ;; Scheme code2 (define (foo1 n)3 (cond4 ((< n 3) n)5 (else (+6 (foo1 (- n 1))7 (* 2 (fo...
2013-07-18 21:24:00 101
转载 The Little Shemer笔记
;;预备函数(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 ()...
2013-07-18 21:23:00 104
转载 函数
1 ;; Common lisp 2 3 ;; define function 4 5 ;; function as the value 6 7 ;; function as the parameter 8 (apply #'+ '(1 2)) 9 (apply (symbol-function '+) '(1 2))10 (apply #'(lambda (x y) (+ ...
2012-03-13 12:37:00 177
转载 Ackerman数学函数
Ackerman数学函数1 ;; Scheme code2 (define (ackermann x y)3 (cond4 ((= y 0) 0)5 ((= x 0) (* 2 y))6 ((= y 1) 2)7 (else (ackermann (- x 1)8 (ackermann x (- y 1))))))...
2011-11-15 15:48:00 127
转载 应用序和正则序
应用序和正则序主要是解释顺序上面的区别.应用序首先对参数求值后再代换,而正则序在代换完全后再归约求值.应用序和正则序测试1 ;; Scheme code2 (define (p) (p))3 4 (define (test x y)5 (if (= x 0)6 07 y))8 9 (test 0 (p))应用序首先对(p)不断...
2011-11-15 14:06:00 193
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人