11 2017 档案

摘要:(define (search f neg-point pos-point) (let ((midpoint (average neg-point pos-point))) (if (close-enough? neg-point pos-point) midpoint (let ((test-value (f midpoint))) ... 阅读全文
posted @ 2017-11-25 03:13 R4mble 阅读(275) 评论(0) 推荐(0)
摘要:let赋值域变量不能从另一个获得 阅读全文
posted @ 2017-11-25 02:21 R4mble 阅读(153) 评论(0) 推荐(0)
摘要:(define (filtered-accumulate filter? combiner null-value term a next b) (define (iter a result) (cond ((> a b) result) ((filter? a) (iter (next a) (combiner (... 阅读全文
posted @ 2017-11-25 01:57 R4mble 阅读(245) 评论(0) 推荐(0)
摘要:(define (filtered-accumulate filter? combiner null-value term a next b) (define (iter a result) (cond ((> a b) result) ((filter? a) (iter (next a) (combiner (... 阅读全文
posted @ 2017-11-25 01:41 R4mble 阅读(359) 评论(0) 推荐(0)
摘要:(define (accumulate combiner null-value term a next b) (define (iter a result) (if (> a b) result (iter (next a) (combiner (term a) result)))) (iter a null-value)) (def... 阅读全文
posted @ 2017-11-25 01:10 R4mble 阅读(287) 评论(0) 推荐(0)
摘要:(define (product term a next b) (if (> a b) 1 (* (term a) (product term (next a) next b)))) (product (lambda (x) x) 1 (lambda (i) (+ i 1)) 5) ... 阅读全文
posted @ 2017-11-25 00:59 R4mble 阅读(237) 评论(0) 推荐(0)
摘要:为什么要把iter塞到sum里面去: 嗯,为了减少通信开销. 回头看递归写法: "我们要以困难的方式搞定它!" 阅读全文
posted @ 2017-11-24 23:37 R4mble 阅读(203) 评论(0) 推荐(0)
摘要:(define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b)))) (define (integral f a b dx) ;积分 (define (add-dx x) (+ x dx)) (* (sum f (+ a (/ dx 2.0)... 阅读全文
posted @ 2017-11-24 23:26 R4mble 阅读(190) 评论(0) 推荐(0)
摘要:对过程的抽象: 填充: 拓展: 阅读全文
posted @ 2017-11-24 23:02 R4mble 阅读(144) 评论(0) 推荐(0)
摘要:(define (next n) (if (= n 2) 3 (+ n 2))) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? n test-divisor) test-divisor) (else (f... 阅读全文
posted @ 2017-11-24 22:00 R4mble 阅读(212) 评论(0) 推荐(0)
摘要:(define (next-odd n) (if (odd? n) (+ 2 n) (+ 1 n))) (define (smallest-divisor n) (find-divisor n 2)) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ... 阅读全文
posted @ 2017-11-24 21:45 R4mble 阅读(236) 评论(0) 推荐(0)
摘要:19919997 阅读全文
posted @ 2017-11-24 21:07 R4mble 阅读(225) 评论(0) 推荐(0)
摘要:你写的算法,银河一号都跑不动. 阅读全文
posted @ 2017-11-24 20:57 R4mble 阅读(109) 评论(0) 推荐(0)
摘要:如果N是合数,则必有一个小于或者等于根号N的素因子. 因为任何合数都可表示为两个或者更多个素数之积. 假如N是合数且其素因子都大于根号N,那么将产生矛盾:根号N*根号N>N.所以合数必有(至少)一个不大于根号N的素因子 阅读全文
posted @ 2017-11-24 13:29 R4mble 阅读(169) 评论(0) 推荐(0)
摘要:用java来跑一跑: 经过我拙劣的比较,对数级比线性还是要好很多的. 阅读全文
posted @ 2017-11-24 12:01 R4mble 阅读(204) 评论(0) 推荐(0)
摘要:(define (double a) (+ a a)) (define (halve a) (/ a 2)) (define (mult a b) (mult-iter a b 0)) (define (mult-iter a b product) (cond ((= b 0) product) ((even? b) (mult-iter (double a... 阅读全文
posted @ 2017-11-24 11:39 R4mble 阅读(132) 评论(0) 推荐(0)
摘要:(define (double x) (+ x x)) (define (halve x) (/ x 2)) (define (mult a b) (cond ((= b 0) 0) ((even? b) (double (mult a (halve b)))) ((odd? b) (+ a (mult a (- b 1)))))) (mult ... 阅读全文
posted @ 2017-11-24 11:33 R4mble 阅读(134) 评论(0) 推荐(0)
摘要:(define (fast-expt b n) (expt-iter b n 1)) (define (expt-iter b n a) (cond ((= n 0) a) ((even? n) (expt-iter (square b) (/ n 2) ... 阅读全文
posted @ 2017-11-23 02:48 R4mble 阅读(229) 评论(0) 推荐(0)
摘要:(define (expte b n) (if (= n 0) 1 (* b (expte b (- n 1))))) ;(expte 2 200000);(expt 2 200000) (define (expta b n) (expta-iter b n 1)) (define (expta-i 阅读全文
posted @ 2017-11-23 02:24 R4mble 阅读(275) 评论(0) 推荐(0)
摘要:define-values: assignment disallowed; cannot change constant constant: expt 你动了语言内置的函数了. 改个名字吧. 阅读全文
posted @ 2017-11-23 02:00 R4mble 阅读(292) 评论(0) 推荐(0)
摘要:(define (pascal row col) (cond ((or (< col 0) (< row 0)) (display"behave yourself!")) ((> col row) (display"behave yourself!")) ((or (= col 0) (= col 阅读全文
posted @ 2017-11-23 01:15 R4mble 阅读(244) 评论(0) 推荐(0)
摘要:递归: (define (f n) (if (< n 3) n (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (- n 3)))))) (f 3) 迭代: (define (f n) (if (< n 3) n (f-iter 0 1 2 n) )) (defin 阅读全文
posted @ 2017-11-23 00:08 R4mble 阅读(290) 评论(0) 推荐(0)
摘要:(define (first-denomination kinds-of-coin) (cond ((= kinds-of-coin 1) 1) ((= kinds-of-coin 2) 5) ((= kinds-of-coin 3) 10) ((= kinds-of-coin 4) 25) ((= 阅读全文
posted @ 2017-11-22 23:16 R4mble 阅读(271) 评论(0) 推荐(0)
摘要:树形递归:计算步骤 随输入 指数性 增长,空间 随输入 线性 增长. 线性迭代:计算步骤 随输入 线性 增长,空间 随输入 线性 增长. 用java写出来看看到底有多厉害: 树形递归程序运行时间:70805ms 而线性迭代绝大部分时候都是0ms. (Java里面函数名不允许 - 这个符号) 阅读全文
posted @ 2017-11-22 20:56 R4mble 阅读(349) 评论(0) 推荐(1)
摘要:(define (A x y) (cond ((= y 0) 0) ((= x 0) (* 2 y)) ((= y 1) 2) (else (A (- x 1) (A x (- y 1)))))) (A 1 10) (A 2 4) (A 3 3) (define (f n) (A 0 n))(f 0 阅读全文
posted @ 2017-11-22 19:59 R4mble 阅读(171) 评论(0) 推荐(0)
摘要:(define (plus-Recursive a b) (if (= a 0) b (inc (plus-Recursive (dec a) b)))) (define (inc n) (+ n 1)) (define (dec n) (- n 1)) (plus-Recursive 3 5) 从 阅读全文
posted @ 2017-11-22 19:45 R4mble 阅读(181) 评论(0) 推荐(0)
摘要:递归: (define (factorial n) (if (= n 1) 1 (* n (factorial(- n 1))))) (factorial 3) 迭代: (define (factorial n) (fact-iter 1 1 n)) (define (fact-iter produ 阅读全文
posted @ 2017-11-22 19:29 R4mble 阅读(164) 评论(0) 推荐(0)
摘要:(define (cube-root x) (cube-root-iter 1.0 x)) (define (cube-root-iter guess x) (if (good-enough? guess x) guess (cube-root-iter (improve guess x) x))) 阅读全文
posted @ 2017-11-22 19:01 R4mble 阅读(228) 评论(0) 推荐(0)
摘要:(define (sqrt-iter guess x) (if (good-enough? guess (improve guess x)) (improve guess x) (sqrt-iter (improve guess x) x))) (define (improve guess x)(a 阅读全文
posted @ 2017-11-22 18:50 R4mble 阅读(204) 评论(0) 推荐(0)
摘要:<一> (define (new-if predicate then-clause else-clause) (cond (predicate then-clause) (else else-clause))) (new-if (= 2 3) 0 5)(new-if (= 1 1) 0 5) new 阅读全文
posted @ 2017-11-22 13:38 R4mble 阅读(273) 评论(0) 推荐(0)
摘要:(define (sqrt-iter guess x) (if (good-enough? guess x) guess (sqrt-iter (improve guess x) x))) (define (improve guess x) (average guess (/ x guess))) 阅读全文
posted @ 2017-11-22 13:04 R4mble 阅读(189) 评论(0) 推荐(0)
摘要:(define (p) (p))(define (test x y) (if (= x 0) 0 y))(test 0 (p)) 哇,这么快就印证了我的想法了吗. 首先用R5RS跑一遍,啥都没有.然后切换成Lazy Racket,结果为0. 解释:前者是应用序,p一传进来就求值,不断的调用自己,无限 阅读全文
posted @ 2017-11-22 12:10 R4mble 阅读(307) 评论(0) 推荐(0)
摘要:(define (a-plus-abs-b a b) (if (> b 0) (+ a b) (- a b)) )(define (a-plus-abs-b-book a b) ((if (> b 0) + -) a b) )(a-plus-abs-b 1 -1)(a-plus-abs-b-book 阅读全文
posted @ 2017-11-22 11:56 R4mble 阅读(193) 评论(0) 推荐(0)
摘要:(define (SumOfTwoLarge x y z) (if (and (<= x y) (<= x z)) (+ (* y y) (* z z)) (SumOfTwoLarge y x z)) )(SumOfTwoLarge 0 2 2) 感觉我这个很取巧啊,哈哈哈哈. 我还是有点不习惯把函 阅读全文
posted @ 2017-11-22 11:44 R4mble 阅读(121) 评论(0) 推荐(0)
摘要:(/ (+ 5 4(- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) 注意: (- 1 1 1 1)这样写也可以 阅读全文
posted @ 2017-11-22 11:27 R4mble 阅读(209) 评论(0) 推荐(0)
摘要:(define a 3) (define b (+ a 1)) b (+ a b(* a b)) (= a b) (if (and (> b a) (< b (* a b))) b a) (cond ((= a 4) 6) ((= b 4) (+ 6 7 a)) (else 25)) (+ 2 (i 阅读全文
posted @ 2017-11-22 11:26 R4mble 阅读(317) 评论(0) 推荐(0)
摘要:1.字段不能用单引号. 2.Invalid default value for TIMESTAMP show variables like 'sql_mode'; set sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES, NO_ZERO_IN_DAT 阅读全文
posted @ 2017-11-16 20:07 R4mble 阅读(165) 评论(0) 推荐(0)
摘要:转载 http://blog.csdn.net/xinghui_liu/article/details/7287662 (1)org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.micr 阅读全文
posted @ 2017-11-14 19:28 R4mble 阅读(444) 评论(0) 推荐(0)
摘要:题目描述:一个由小写字母组成的字符串可以看成一些同一字母的最大碎片组成的。例如,"aaabbaaac"是由下面碎片组成的:'aaa','bb','c'。牛牛现在给定一个字符串,请你帮助计算这个字符串的所有碎片的平均长度是多少。 小技巧:每一种碎片长度加起来就是整个字符串的长度,所以没必要算出单独的长 阅读全文
posted @ 2017-11-14 00:30 R4mble 阅读(255) 评论(0) 推荐(0)
摘要:题目描述:为了得到一个数的"相反数",我们将这个数的数字顺序颠倒,然后再加上原先的数得到"相反数"。例如,为了得到1325的"相反数",首先我们将该数的数字顺序颠倒,我们得到5231,之后再加上原先的数,我们得到5231+1325=6556.如果颠倒之后的数字有前缀零,前缀零将会被忽略。例如n = 阅读全文
posted @ 2017-11-13 23:38 R4mble 阅读(1152) 评论(0) 推荐(0)
摘要:题目描述:小易准备去魔法王国采购魔法神器,购买魔法神器需要使用魔法币,但是小易现在一枚魔法币都没有,但是小易有两台魔法机器可以通过投入x(x可以为0)个魔法币产生更多的魔法币。魔法机器1:如果投入x个魔法币,魔法机器会将其变为2x+1个魔法币魔法机器2:如果投入x个魔法币,魔法机器会将其变为2x+2 阅读全文
posted @ 2017-11-13 21:47 R4mble 阅读(183) 评论(0) 推荐(0)