- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 练习2.53-练习2.56
1.练习2.53 '(a b c) '((george)) '((y1 y2)) '(y1 y2) #f #f '(red shoes blue socks) 2.练习2.54 (define (equal? s1 s2) (cond ((and (null? s1) (null? s2)) true) ((or (null? s1) (null? s
2014-01-23 19:10:57 564
原创 练习2.48-练习2.51
1.练习2.48 (define (make-segment start end) (cons start end)) (define (start-segment seg) (car seg)) (define (end-segment seg) (cdr seg)) 2.练习2.49 (require (planet "sicp.ss" ("soegaard" "sicp
2014-01-22 19:12:03 585
原创 练习1.23-练习1.30
1.练习1.23 改后的代码如下: (define (find-divisor-better n a) (cond ((> (square a) n) n) ((divides?-better n a) a) (else (find-divisor-better n (next-2 a))))) (define (next-2 n) (if (= 2 n) (+ 1
2014-01-20 20:10:43 575
原创 练习2.21-练习2.35
1.练习2.21 (define (square-list items) (if (null? items) '() (cons (square (car items)) (square-list (cdr items))))) (define (square-list items) (map (lambda (x) (square x)) items)) 2
2014-01-20 20:10:25 597
原创 练习2.41-练习2.47
1.练习2.41 (define (seprate-except x except) (filter (lambda (couple) (let ((first (car couple)) (second (cadr couple))) (and (not (= first except))
2014-01-20 18:59:14 620
原创 练习2.11-练习2.20
1.练习2.11 (define (mul-interval x y) (let ((x1 (lower-bound x)) (x2 (upper-bound x)) (y1 (lower-bound y)) (y2 (upper-bound y))) (let ((zzx (and (>= x1 0) (>= x2 0))) (zzy (and (>= y1 0) (>
2014-01-17 21:42:30 566
原创 练习2.2-练习2.10
1.练习2.2 (define (make-segment start end) (cons start end)) (define (start-segment seg) (car seg)) (define (end-segment seg) (cdr seg)) (define (make-point x y) (cons x y)) (define (x-poin
2014-01-15 21:29:45 561
原创 练习2.1
1.练习2.1 (define (check-pos-neg a b) (or (and (not ( b 0)) (and (not (> a 0)) (< b 0)))) (define (make-rat n d) (let ((g (gcd (abs n) (abs d))) (posi (check-pos-neg n d))) (cons (/ (if
2014-01-14 22:59:32 493
原创 练习1.40-练习1.46
1.练习1.40 (define (cubic a b c) (define (cube x) (* x x x)) (lambda (x) (+ (cube x) (* a (square x)) (* b x) c))) (define (newtons-method g guess) (fixed-point (ne
2014-01-13 21:01:26 628
原创 练习1.35-练习1-38
1.练习1.35 (fixed-point (lambda (x) (+ 1 (/ 1 x))) 1.0) 2.练习1.36 不用平均阻尼方式: (fixed-point-display (lambda (x) (/ (log 1000) (log x))) 2.0) 结果为: 2. 9.965784284662087 3.004472209841214 6.2791957575071
2014-01-11 23:07:30 463
原创 练习1.31-练习1.34
最近对于Lisp的强大和高深还是深有体会的,可以将函数作为参数进行调用,这样在很大的程度上可以提高函数的抽象性,即将具有公共模式的函数进行抽象。例如在SICP中,首先将累加和的过程进行了抽象,然后在累加和的基础上抽象出了累乘积,进而又发现了累加和与累乘积的共同点,进一步抽象成了一个叫做accumulate的函数,这个函数的是这样的 (accumulate combiner null-value
2014-01-10 19:19:02 536
原创 练习1.23-练习1.30
1.练习1.23改后的代码如下: (define (find-divisor-better n a) (cond ((> (square a) n) n) ((divides?-better n a) a) (else (find-divisor-better n (next-2 a))))) (define (next-2 n) (if (= 2 n) (+
2014-01-09 21:05:38 470
原创 练习1.18-练习1.22
1.练习1.18 (define (*-iter a b n) (cond ((= n 0) a) ((even? n) (*-iter a (double b) (halve n))) (else (*-iter (+ a b) b (- n 1))))) (define (* b n) (*-iter 0 b n)) Lisp真是强大啊,连 *-iter这种函数名也可以使用!
2014-01-08 21:33:03 665
原创 练习1.10-练习1.17
1.练习1.10 表达式的求值就不说了。 (define (f n) (A 0 n)) -------2n (define (g n) (A 1 n))-------2的n次方 (define (h n) (A 2 n))-------n个2的次方,例如:(h 4)表示为2的2次方的2次方的2次方 2.练习1.11 递归计算过程: (define (f1 n) (if (< n
2014-01-07 20:47:31 590
原创 练习1.1-练习1.9
1. 练习1.1 这个题没有什么好说的了,只要把代码敲出来,运行一遍就可以了。 2. 练习1.2 这个题应该不算难吧,没有看过别人的答案,我把我的贴出来吧。 (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) 3.练习1.3 我的方法是求出3个数的和,再将减去最小的数,算不上最好的方法吧,马马虎虎。 (def
2014-01-06 21:20:53 632
转载 别人的Emacs配置1
原地址:点击打开链接 ;;使用C-x C-e检测配置的正确性 (global-linum-mode t);显示行号 (setq column-number-mode t);显示列号 (setq auto-image-file-mode t);让Emacs可以直接打开和显示图片 (auto-compression-mode t);打开压缩文件时自动解压缩 ;(setq global-font-lo
2014-01-04 17:24:10 1042
原创 Emacs 配置之查找是否有“*scheme*”窗口
最近终于下定决心学习一下lisp,打算从SICP开始吧。 编辑器打算采用Emacs,原因是它是用C和Emacs Lisp(Lisp的一种方言)编写的程序。 Emacs还真的是难学啊,在掌握了基本(基本)的操作后,开始配置Emacs的环境,参考的很多网上的一些代码,就不多说了。 这里要说的是我在借鉴了大牛王垠的配置后,在使用的时候会报一个找不到find函数的的错误,源代码如下: (defun
2014-01-04 17:14:24 608
转载 Emacs安装和设置tabbar
点击打开链接 Emacs是用Buffer来组织编辑区域的,一个Buffer就代表一个文件或者一个临时编辑区域,我们可以用一些函数来切换到前一个或后一个Buffer,也可以列出所有的Buffer来进行选择。一些现代编辑器都支持一种特性,那就是Tab,用标签来列出所有的文件并可以方便地在文件之间切换,直观而方便。万能的Emacs当然也可以做到这个。 增加标签特性需要tabbar
2014-01-03 00:09:51 1470
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人