今天回到屋子先睡了一觉,昨天没休息好,打了一宿蚊子,战果丰盛。睡醒后,开始,找一些好听的音乐。最后该看书了,继续我的The Little Scheme。本来,我是先看SICP的,但是,看着看着不知怎么就跑到这本书了。还好这本比较薄,马上就要看完了。接下来,写了几个习题:
(define atom?
(lambda (x)
(not (or (null? x) (pair? x)))))
(define insertR*
(lambda (old new lat)
(cond
((null? lat) '())
((atom? (car lat))
(cond
((eq? old (car lat))
(cons (car lat) (cons new (insertR* old new (cdr lat)))))
(else (cons (car lat) (insertR* old new (cdr lat))))))
(else
(cons (insertR* old new (car lat)) (insertR* old new (cdr lat)))))))
用Scheme写程序就是一个字:爽。
比较两个list相等:
(define eqlist*
(lambda (lat1 lat2)
(cond
((and (null? lat1) (null? lat2)) #t)
((or (null? lat1) (null? lat2)) #f)
((and (atom? (car lat1)) (atom? (car lat2))) (and (eq? (car lat1) (car lat2)) (eqlist* (cdr lat1) (cdr lat2))))
(else (and (eqlist* (car lat1) (car lat2)) (eqlist* (cdr lat1) (cdr lat2)))))))
分享到:
相关推荐
文件包含: [the little scheme.pdf] 书上的例子源码, windows运行环境(执行scheme程序), 和其姊妹篇 [The Seasoned Schemer.pdf] 文件
the little scheme 4th epub 适合电子书阅读的版本 可以直接再很多电子书上阅读 The.Little.Schemer.4th The.Little.Schemer.4th.mobi
scheme源代码scheme 阴阳题源代码
The Little Typer explains dependent types, beginning with a very small language that looks very much like Scheme and extending it to cover both programming with dependent types and using dependent ...
《The Little Schemer:递归与函数式的奥妙》介绍了Scheme的基本结构及其应用、Scheme的五法十诫、Continuation-Passing-Style、Partial Function、Y-Combinator、Interpreter等内容,并通过这些内容阐述了计算的...
This thoroughly updated edition of The Scheme Programming Language provides an introduction to Scheme and a definitive reference for standard Scheme, presented in a clear and concise manner....
《The Little Scheme》英文版第四版PDF。
The Scheme Programming Language
The Scheme Programming Language 和书中的习题答案两个文件
Wavelets and the Lifting Scheme A 5 Minute Tour
The Scheme Programming Language Third_Edition pdf版
The scheme programming language scheme语言中的The c programming language.很经典,较第三版增加了不少内容,可读性更强,让您充分体会函数式编程的魅力。
The Scheme Programming Language, 4th Edition - R. Kent Dybvig.azw3 排版良好。
The fourth edition has been substantially revised and expanded to bring the content up to date with the current Scheme standard, the Revised6 Report on Scheme. All parts of the book were updated and ...
The Referential Solution on the Connection Scheme between PLC System and Sensorpdf,The Referential Solution on the Connection Scheme between PLC System and Sensor
mit-scheme源代码,可用于在64位Linux系统编译。
scheme and the art of programming
The Little Typer explains dependent types, beginning with a very small language that looks very much like Scheme and extending it to cover both programming with dependent types and using dependent ...