sicp习题试解 (1.40)

类别:编程语言 点击:0 评论:0 推荐:

; ======================================================================
;
; Structure and Interpretation of Computer Programs
; (trial answer to excercises)
;
; 计算机程序的构造和解释(习题试解)
;
; created: code17 03/06/05
; modified:
; (保持内容完整不变前提下,可以任意转载)
; ======================================================================


;; SICP No.1.40

(define (cubic a b c)
(lambda (x) (+ (* x x x) (* a x x) (* b x) c)))


;; Test-it:
;; Welcome to MzScheme version 209, Copyright (c) 2004 PLT Scheme, Inc.
;; > (newtons-method (cubic 0 0 1) 2.0)
;; -0.9999999999999755 ;; when x^3+1=0
;; > (newtons-method (cubic 1 1 -3) 100)
;; 1.000000000000019 ;; when x^3+x^2+x-3=0

本文地址:http://com.8s8s.com/it/it23021.htm