1.42
(define (my-compose f g)
(lambda (x)
(f (g x))))
(define (inc x)
(+ x 1))
(define (square x)
(* x x))
((my-compose square inc) 6)
1.43
(define (my-compose f g)
(lambda (x)
(f (g x))))
(define (inc x)
(+ x 1))
(define (square x)
(* x x))
((my-compose square inc) 6)
(define (repeated f n)
(if (= n 1)
f
(compose f (repeated f (- n 1)))))
(define (my-repeated f n)
(lambda (x)
(if (= n 1)
(f x)
((my-compose f (my-repeated f (- n 1))) x))))
((repeated square 3) 5)
((my-repeated square 3) 5)
1.44
(define (square x)
(* x x))
(define (composed f g)
(lambda (x)
(f (g x))))
(define (repeated f n)
(if (= n 1)
f
(composed f (repeated f (- n 1)))))
(define dx 0.00001)
(define (smooth f)
(lambda (x)
(/ (+ (f (- x dx)) (f x) (f (+ x dx))) 3)))
(define (n-smooth n f)
((repeated smooth n) f))
((smooth square) 2)
((smooth (smooth square)) 2)
((smooth (smooth (smooth square))) 2)
((n-smooth 3 square) 2)
1.45
(define tolerance 0.00001)
(define dx 0.00001)
(define (square x)
(* x x))
(define (average a b)
(/ (+ a b) 2))
(define (composed f g)
(lambda (x)
(f (g x))))
(define (repeated f n)
(if (= n 1)
f
(composed f (repeated f (- n 1)))))
(define (fixed-point f first-guess)
(define (close-enough? v1 v2)
(< (abs (- v1 v2)) tolerance))
(define (try guess)
(let ((next (f guess)))
(newline)
(display next)
(if (close-enough? guess next)
next
(try next))
))
(try first-guess))
(define (power x n)
(if (= n 1)
x
(* x (power x (- n 1)))))
(define (times i)
(if (< i 2)
0
(+ 1 (times (/ i 2)))))
(define (average-damp f)
(lambda (x)
(average x (f x))))
(define (n-average-damp n f)
((repeated average-damp n) f))
(define (my-sqrt x)
(fixed-point (average-damp (lambda (y) (/ x y))) 1.0))
(define (my-sqrt-n x n)
(fixed-point (n-average-damp (- (times n) 1) (average-damp (lambda (y) (/ x (power y (- n 1)))))) 1.0))
;;(my-sqrt-n 64 3)
(my-sqrt-n 64 7)
(my-sqrt-n 64 8)
(my-sqrt-n 64 15)
(my-sqrt-n 64 31)
(my-sqrt-n 64 63)
1.46
(define (iterative-improve good-enough? improve)
(define (try-it x)
(if (good-enough? x)
x
(try-it (improve x))))
(lambda (x)
(try-it x)))
(define (sqrt x)
(define (good-enough? guess)
(< (abs (- (square guess) x)) 0.001))
(define (improve guess)
(average guess (/ x guess)))
((iterative-improve good-enough? improve) 1.0))
(sqrt 2)
分享到:
相关推荐
SICP 习题答案 计算机程序的构造和解释 1-3章 习题答案
SICP习题解答,主要第一章的内容习题答案
NULL 博文链接:https://pengpeng.iteye.com/blog/1344689
sicp in python 中文版 sicp in python 中文版 sicp in python 中文版 !!!download>>>https://github.com/wizardforcel/sicp-py-zh
SICP中文第二版SICP中文第二版SICP中文第二版SICP中文第二版SICP中文第二版
scheme编译器最新版,Windows下直接安装即可运行,sicp刷题必备。祝大家早日学到sicp之精髓~
SICP-Python版本
SICP 使用的scheme解释器 以前叫DrScheme
sicp 2.2.4节图形语言的racket程序包,配置路径,C:\Users\Administrator\AppData\Roaming\Racket
Python SICP epub版本,很适合学习抽象的思想,用Python版本比lisp更实用
SICP 解题集
SICP CHINESE ENGLISH THE SECOND EDITION SICP CHINESE ENGLISH THE SECOND EDITION
sicp in python 中文版 sicp in python 中文版 sicp in python 中文版 download : https://github.com/wizardforcel/sicp-py-zh
sicp 2ed高清pdf,以及相对应的mit课程资料及习题答案打包,中文版的视频在这里http://i.youku.com/i/UNTcxODk3ODQw/videos?spm=a2hzp.8244740.0.0
资源来自pypi官网。 资源全名:sicp-0.0.1b102.dev4.tar.gz
sicp-in-python(中文版+英文版)PDF 背景. SICP 全称Structure and Interpretation of Computer Programs,翻译过来叫《计算机程序的构造和解释》使用python
资源名称:sicp 和 操作系统:精髓与设计原理第七版资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。
SICP_章_1-3 我对SICP第二版第1-3章的解决方案: 书中练习来自示例分配/ psets 项目位于 最后,来自考试
经典书籍《计算机程序的构造与解释》,UCB热门课程CS61a的官方教材