1.38
(define (cont-frac n d i k)
(if (= k 1)
(/ (n 1) (d 1))
(/ (n i) (+ (d i) (cont-frac n d (+ i 1) (- k 1))))))
(define (cont-frac-r n d k)
(define (frac i)
(if (= i (+ k 1))
0
(/ (n i) (+ (d i) (frac (+ i 1))))))
(frac 1))
(define (cont-frac-i n d k)
(define (frac i v)
(if (= i 0)
v
(frac (- i 1) (/ (n i) (+ (d i) v)))))
(frac k 0))
(cont-frac-r (lambda (i) 1.0)
(lambda (i) 1.0)
11)
(define (frac n)
(if (= (remainder (- n 2) 3) 0)
(* 2 (+ (/ (- n 2) 3) 1))
1))
(cont-frac-r (lambda (i) 1.0)
(lambda (i)
(if (= (remainder (- i 2) 3) 0)
(* 2 (+ (/ (- i 2) 3) 1))
1))
1000)
1.39
(require (lib "math.ss"))
(define (tan-cf x k)
(define (d i)
(- (* 2 i) 1))
(define (n i)
(if (= i 1)
x
(- (* x x))))
(define (frac i)
(if (= i (+ k 1))
0
(/ (n i) (+ (d i) (frac (+ i 1))))))
(frac 1))
(tan-cf (/ pi 4) 10)
(tan-cf (- (/ pi 4)) 10)
(tan-cf (/ pi 8) 10)
1.40
(define (square x)
(* x x))
(define (cube x)
(* x x x))
(define tolerance 0.00001)
(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 (deriv g)
(lambda (x)
(/ (- (g (+ x dx)) (g x))
dx)))
(define dx 0.00001)
(define (newton-transform g)
(lambda (x)
(- x (/ (g x) ((deriv g) x)))))
(define (newton-method g guess)
(fixed-point (newton-transform g) guess))
(define (cubic-deriv a b c)
(lambda (x)
(+ (* 3 (square x)) (* 2 a x) b)))
(define (cubic a b c)
(lambda (x)
(+ (* (cube x)) (* a (square x)) (* b x) c)))
(newton-method (cubic 1 2 3) 1)
;;((cubic 1 1 1) 1)
1.41
(define (double proc)
(lambda (x)
(proc (proc x))))
(define (inc x)
(+ x 1))
((double inc) 1)
(((double double) inc) 1)
(((double (double double)) inc) 1)
分享到:
相关推荐
《计算机程序的构造和解释》...通过解答SICP的习题,读者将深入理解这些概念,并能运用到实际的编程实践中。习题旨在促进对这些基本原理的深入思考,帮助程序员建立坚实的基础,进而在面对复杂的编程挑战时能游刃有余。
以上就是基于文件名推测的SICP第二章练习题相关知识点。这些内容深入地涵盖了函数式编程的基础和应用,对于提升编程思维和技能大有裨益。实际的学习过程中,通过阅读和理解这些代码,结合原书的理论部分,将有助于...
《SICP习题解答,主要第一章的内容习题答案》 SICP,全称《Structure and Interpretation of Computer Programs》(计算机程序的构造和解释),是计算机科学领域的一本经典教材,由MIT(麻省理工学院)的 Harold ...
SICP中文第二版SICP中文第二版SICP中文第二版SICP中文第二版SICP中文第二版
在" sicp-master "这个压缩包中,可能包含的是对SICP各章节练习题的解答,包括源代码、注释和分析。这些练习通常涵盖了函数式编程的基础,如高阶函数、递归、闭包,以及更高级的主题,如过程构造、数据结构、环境...
sicp in python 中文版 sicp in python 中文版 sicp in python 中文版 !!!download>>>https://github.com/wizardforcel/sicp-py-zh
《SICP解题集》是一份专注于探讨和解答《结构与解释程序》(Structure and Interpretation of Computer Programs,简称SICP)一书中习题的资源。SICP是计算机科学领域的一本经典教材,由Harold Abelson、Gerald Jay ...
"sicp-solutions"是一个针对该书练习题的解答集,主要使用了Scheme语言,一个Lisp方言,而具体的实现环境是mit-scheme 9.2。 Scheme语言是Lisp家族的一员,以其简洁的语法和强大的函数式编程特性闻名。在"sicp-...
《计算机程序的构造与解释》(Structure and Interpretation of Computer Programs,简称SICP)是一本备受推崇的经典计算机科学教材,由Harold Abelson和Gerald Jay Sussman撰写,并由MIT出版社出版。这本书以其深入...
scheme编译器最新版,Windows下直接安装即可运行,sicp刷题必备。祝大家早日学到sicp之精髓~
《SICP 2.2.4 节:图形语言》是计算机科学经典教材《结构与解释程序》(Structure and Interpretation of Computer Programs)中的一个重要章节,它深入介绍了如何利用编程来创建图形,以及如何设计和理解复杂的计算...
《计算机程序构造和解释》(SICP,Structure and Interpretation of Computer Programs)是一本具有深远影响力的计算机...压缩包中的“SICP 北大课件”文件可能包含课件、讲义、习题解答等资料,是学习SICP的宝贵资源。
SICP-Python版本
SICP 使用的scheme解释器 以前叫DrScheme
Python SICP epub版本,很适合学习抽象的思想,用Python版本比lisp更实用
《SICP》全称是《Structure and Interpretation of Computer Programs》,中文译为《计算机程序的构造和解释》。这是一本经典的计算机科学教材,由Harvard大学的 Harold Abelson 和 Gerald Jay Sussman 教授撰写,...
标题中的"PyPI 官网下载 | sicp-0.0.1b102.dev4.tar.gz"指的是从Python的官方包索引(Python Package Index,简称PyPI)上下载的一个名为"sicp"的软件包的版本号为0.0.1b102.dev4的压缩文件,其格式是tar.gz。...
本书名为《a_book_sicp_py》,是一本以Python语言为基础介绍设计模式和计算机科学基础的书籍。根据描述和部分内容,可以提炼出以下知识点: 1. 编程语言的重要性:在计算机科学的宽泛领域中,编程语言扮演着至关...
sicp in python 中文版 sicp in python 中文版 sicp in python 中文版 download : https://github.com/wizardforcel/sicp-py-zh