把 SICP 学了一遍,这里是我写的所有习题。
- 第一章:26 道
- 第二章:88 道
- 第三章:81 道
- 第四章:61 道
- 第五章:21 道
共计:277 道。
写了一篇博客,介绍我的学习感受和一些心得:我如何用二十天刷完 SICP。
我没有完成全部习题,没做的那些题主要是:
- 证明题:数量很少
- 图表题:编辑器画不了图,我尽量用文字表示
- 太难的题:主要集中在最后一章
此外,我的答案仅供参考。欢迎讨论交流,不欢迎喷。
基于WTFPL协议开源。
收录我完成的练习题
把 SICP 学了一遍,这里是我写的所有习题。
共计:277 道。
写了一篇博客,介绍我的学习感受和一些心得:我如何用二十天刷完 SICP。
我没有完成全部习题,没做的那些题主要是:
此外,我的答案仅供参考。欢迎讨论交流,不欢迎喷。
基于WTFPL协议开源。
题目见 http://sarabander.github.io/sicp/html/3_002e4.xhtml#Exercise-3_002e39
你的答案如下
; except two normal value, there are one special case
; second proc read x before first set! works (after square operator, because set! is not included in serializer), so result is 11.
但是我认为,那个 special case 的答案是 100, 而11的情况不会发生
网络上的其他资源也与我的判断一致:
我的思考过程是这样:
(lambda () (set! x ((s (lambda () (* x x))))))
(s (lambda () (set! x (+ x 1))))
第一行的函数会进行两个 process : 1. 计算新的值(计算新值的过程是 atomic 的,这一点由 serializer 保证)(我把这个操作记为p); 2. 赋值给x(我把这个操作记为q)
第二行的函数进行一个操作: 计算新值并赋值(整个过程是 atomic 的)(我把这个操作记作a)
如果整个程序以"paq"的顺序发生,那么结果就是100
(啊开学前看不完SICP要死了orz
; mit-scheme 没有nil这个概念,这道题本身就是错的
(define (map p sequence)
(accumulate (lambda (x y) (cons x (p y)) ) () sequence))
; 序列反了
(define (append seq1 seq2)
(accumulate cons seq2 seq1))
; 会报错,参数少一个
(define (length sequence)
(accumulate (lambda (x) (+ x 1)) 0 sequence))
We should reset the counter upon one successful login to fulfil consecutive requirement?
consider the following examples:
6 consecutive failed login
1 successful login
2 consecutive failed login -> will still call the cops
(btw thanks for the solutions and great writeup !)
if 的條件判斷和思路是對的,但是求值過程寫錯了。
(define (e13 a b c )
(cond ((and (<= a b) (<= a c)) (+ (square b) (square c)))
((and (<= b a) (<= b c)) (+ (square a) (square c)))
(else (+ (square a) (square b)))
)
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.