摘要: 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))))))这是个神马函数,增长速度太快(ackermann 4 3)就把我内存算爆掉.前面几个简单序列1 (define (foo1 n) (ackermann 0 n))2 // The value is 2*n3 4 (de... 阅读全文
posted @ 2011-11-15 15:48 maxima 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 应用序和正则序主要是解释顺序上面的区别.应用序首先对参数求值后再代换,而正则序在代换完全后再归约求值.应用序和正则序测试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)不断求值,陷入无限循环,正则序首先完全展开表达式,后求值为0.为什么if是特殊表达式if语法是这个样子的 (if predicate then-clause else-clause)当predicate为真的时候只对then-clause求值,而... 阅读全文
posted @ 2011-11-15 14:06 maxima 阅读(537) 评论(0) 推荐(0) 编辑