태그>sicp(총 219개의 글)
'sicp' 관련 최근글
-
- 연습문제 1.20

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|07/06 12:15
인자 먼저 계산하는 방법 (gcd 206 40) > (if (= 40 0) 206 (gcd 40 (reminder 206 40)) ) (gcd 40 (reminder 206 40)) (gcd 40 6) - 1 > (if (= 6 0) 40 (gcd 6 (reminder 40 6)) ) (gcd 6 (reminder 40 6)) (gcd 6 4) - 2 > (if (= 4 0) 6 (gcd 4 (re..
- 연습문제 1.20
-
- 연습문제 1.19

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|07/06 11:28
> (define (fib-iter a b p q count) (cond ((= count 0) b) ((even? count) (fib-iter a b (+ (* p p) (* q q)) (+ (* q q) (* 2 p q)) (/ count 2))) (else (fib-iter (+ (* b q) (* a q) (* a p)) (+ (* b q) (* a q)) p
- 연습문제 1.19
-
- 연습문제 1.17

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|07/05 23:47
계속해서 반복되는 프로세스로 문제를 풀다보니 18번부터 불어버렸네요;; > (define (fast-times b c) (define (double k) (* k 2)) (define (halve k) (/ k 2)) (cond ((= c 0) 0) ((even? c) (fast-times (double b) (halve c))) (..
- 연습문제 1.17
-
- 연습문제 1.18

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|07/05 23:23
> (define (fast-times b c) (define (double k) (* k 2)) (define (times-iter a b c) (cond ((= c 0) a) ((even? c) (times-iter (+ a (double b)) b (- c 2))) (else (times-iter (+ a b) b (- c 1))))) (times-iter ..
- 연습문제 1.18
-
- 연습문제 1.16

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|07/05 22:45
귀띔 덕분에 쉽게 풀었습니다. > (define (fast-expt b n) (define (expt-iter a b n) (if (= n 0) a (expt-iter (* a b) b (- n 1)))) (expt-iter 1 b n)) > (fast-expt 3 1000) 13220708194808066368904552597521443659654220327521481676649203682268285973467048995407783138506080619639097..
- 연습문제 1.16
-
- 연습문제 1.14

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|06/30 22:59
동전바꾸기 문제를 분석하는 문제입니다. 일단 > (define (count-change amount) (cc amount 5)) > (define (cc amount kinds-of-coins) (cond ((= amount 0) 1) ((or (< amount 0) (= kinds-of-coins 0)) 0) (else (+..
- 연습문제 1.14
-
- 연습문제 1.12

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|06/23 02:16
> (define (pascal row col) (cond ((<= row col) 1) ((= col 1) 1) (else (+ (pascal (- row 1) (- col 1)) (pascal (- row 1) col))))) 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 처음에는 이런 파스칼의 삼각형을 모두 출력하는 문제 인 줄 알았는데 다른..
- 연습문제 1.12
-
- 1.8 newton's method 3제곱근 구하기

-
Blah blah blah! by Edmond Dantes|06/05 11:56
(define (square x) (* x x))(define (cube x) (* x x x)) (define (cube-root x) (cube-root-iter 1.0 x))(define (cube-root-iter guess x) (if(good-enough? guess x) guess (cube-root-iter (improve guess x)..
- 1.8 newton's method 3제곱근 구하기
-
- newton's method

-
Blah blah blah! by Edmond Dantes|06/05 10:21
(define (abs a) (cond((< 0 a) (- a)) (else a))) (define (square a) (* a a)) (define (sqrt-iter guess x) (if(good-enough? guess x) guess (sqrt-iter (improve guess x) x)))..
- newton's method
-
- 연습문제 1.11

-
정의를 말할 수 있는 젊은이가 되고 싶다 by 빵사장님|05/28 00:39
recursive process 로 작성한 것 > (define (f n) (cond ((< n 3) n) (else ( + (- n 1) (* 2 (f (- n 2))) (* 3 (f (- n 3))))) ) ) iterative process 로 작성한 것 > (define (f2 n) (define (f-iter it n1 n2 n3) (if (= it n) ..
- 연습문제 1.11
-
- 연습문제 1.10

-
진짜 중요한건 코드한줄 잘 짜는게 아니다! by 빵사장님|05/26 01:05
> (define (A x y) (cond ((= y 0) 0) ((= x 0) (* 2 y)) ((= y 1) 2) (else (A (- x 1) (A x (- y 1)))))) 애커만 함수를 구현한 프로시저이다. 구글에서 애커만 함수에 대해서 좀 찾아봤는데 책에서 설명하고 있는 프로시저와 달라서 ( 영..
- 연습문제 1.10
-
- 연습문제 1.9

-
진짜 중요한건 코드한줄 잘 짜는게 아니다! by 빵사장님|05/22 00:20
> (define (inc x) (+ x 1)) > (define (dec x) (- x 1)) > (define (plus a b) (if (= a 0) b (inc (plus (dec a) b) ) )) > (plus 4 5) > (inc (plus 3 5)) > (inc (inc (plus 2 5))) > (inc (inc (inc..
- 연습문제 1.9
-
- 1.2.1 되돌거나(recursioni) 반복하는(iteration) 프로세스

-
진짜 중요한건 코드한줄 잘 짜는게 아니다! by 빵사장님|05/21 23:57
오늘은 양이 좀 많다;; 새로운 용어가 많이 나와서 그런듯. factorial 함수를 구현한다고 했을 때 1. recursion 을 이용 > (define (factorial n) (if (= n 1) 1 (* n (factorial (- n 1))))) > (factorial 6) 720 recursion을 이용하면 연산을 바로 계산 할 수 없..
- 1.2.1 되돌거나(recursioni) 반복하는(iteration) 프로세스
-
- 블랙박스처럼 간추린 프로시저

-
진짜 중요한건 코드한줄 잘 짜는게 아니다! by 빵사장님|05/21 01:57
> (define (sqrt2 x) (define (square x1) (* x1 x1)) (define (good-enough? guess) (< (abs (- (square guess) x) ) 0.001)) (define (average x1 x2) (* (+ x1 x2) 0.5)) (define (improve guess) (average gues..
- 블랙박스처럼 간추린 프로시저
-
- 연습문제 1.8

-
진짜 중요한건 코드한줄 잘 짜는게 아니다! by 빵사장님|05/18 00:42
세제곱근에 대해서 앞에 문제를 푸는 문제이다. 근데 책에 주어진 공식이 잘못되었다;; x(i+1) = (a + x^2 + 2x ) / 3 이렇게 하면 발산하게 된다 ㅡㅡ;; 그래서 wikipedia에서 newton cube root 검색 > (define (improve guess x) (/ (+ (/ x (square gu..
- 연습문제 1.8







