redmix


Joined 2 years ago
Homeworks submitted:
Homework comments:
1
0

About Me

No description provided.

Classes

Structure and Interpretation of Computer Programs

Class status: Established
Role: Student
. 7% complete

Submitted Assignments

Structure and Interpretation of Computer Programs: Lesson 1, HW 1

Ex 1.2

(/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (6-2) (2-7)))

======== Ex 1.3 ========

(define (square x) (* x x))

(define (sum-of-squares x y) (+ (square x) (square y)))

(define (f i j k) (cond (and ( ) )

add a to the absolute value of b if b is greater than 0 the operand is +. Else, the operand is -. if the operand is + a and b are added. if the operand is - a and b are subtracted. b is a negative number so this is the same as adding b's absolute

value.

======== Ex 1.5 ======== app order: p keeps on trying to be defined, but isn't

normal: 0 p never tries to get defined

;**late ex 1.8**

(define (cube-iter guess x)
  (if (good-enough? guess x)
      guess
      (cube-iter (improve guess x)
                 x)))

;this should be improved!
(define (good-enough? guess x)
  (< (abs (- (cube guess) x)) 0.001))


(define (abs x)
  (if (< x 0)
      (- x)
      x))

(define (improve guess x)
  (/ (+ (/ x (square guess)) (* 2 guess)) 3)


(define (cube x) (* x x x))

(define (cuberoot x)
  (cube-iter 1.0 x))

redmix 2 years ago