Hatena::Groupcsnagoya-sicp

YasuyukiMiuraの日記

2008-11-22

07:25

1.20 - クラなんとかの日記 - CSNagoya-SICPグループの長いコードがListと表示された件を試してみる。

;; 展開前
(gcd 206 40)

;; 1st expand (一回目の展開)
;; remainder : 0 回使用
(if (= 40 0) ; => #f
    206
    (gcd 40
         (remainder 206 40)))

;; if の展開
(gcd 40
     (remainder 206 40))

;; 2nd expand (二回目の展開)
;; remainder : 1 回使用(if の条件式部で 1回,現在 0回)
(if (= (remainder 206 40) 0) ; => (= 6 0) => #f
    40
    (gcd (remainder 206 40)
         (remainder 40 (remainder 206 40))))

;; if condition (if の条件式部分の展開)
(gcd (remainder 206 40)
     (remainder 40 (remainder 206 40)))

;; 3rd expand (3回目の展開)
;; remainder : 3 回使用(if の条件式部で 2回,現在 1回)
(if (= (remainder 40 (remainder 206 40)) 0) ; => (= (remainder 40 6) 0) => (= 4 0) => #f
    (remainder 206 40)
    (gcd (remainder 40 (remainder 206 40))
         (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))))

;; if condition (if の条件式の展開)
(gcd (remainder 40 (remainder 206 40))
     (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))

;; 4th expand (4回目の展開)
;; remainder : 7 回使用(if の条件式部で 4回,現在 3回)
(if (= (remainder (remainder 206 40) (remainder 40 (remainder 206 40))) 0) ; (= (remainder 6 (remainder 40 6)) 0) => (= (remainder 6 4) 0) => (= 2 0) => #f
    (remainder 40 (remainder 206 40))
    (gcd (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
         (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))))

;; if condition (if の条件式の展開)
(gcd (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
     (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))))

;; 5th expand (5回目の展開)
;; remainder : 14 回使用(if の条件式部で 7回,現在 7回)
(if (= (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))) 0) ; (= (remainder (remainder 40 6) (remainder 6 (remainder 40 6))) 0) => (= (remainder 4 (remainder 6 4)) 0) => (= (remainder 4 2) 0) => (= 0 0) => #t
    (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
    (gcd (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))
         (remainder (remainder (remainder 206 40) (remainder 40 (remainder 206 40))) (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))))))

;; if condition (if の条件式の展開)
;; remainder : 18 回使用(全体で 4回,現在 14回)
(remainder (remainder 206 40) (remainder 40 (remainder 206 40)))

;; 計算1
(remainder 6 (remainder 40 6))

;; 計算2
(remainder 6 4)

;; 計算3
2
;; 展開前
(gcd 206 40)

;; 1st expand (一回目の展開)
;; remainder : 0 回使用
(if (= 40 0) ; => #f
    206
    (gcd 40
         (remainder 206 40)))

;; if の展開
(gcd 40
     (remainder 206 40))

;; 2nd expand (二回目の展開)
;; remainder : 1 回使用(if の条件式部で 1回,現在 0回)
(if (= (remainder 206 40) 0) ; => (= 6 0) => #f
    40
    (gcd (remainder 206 40)
         (remainder 40 (remainder 206 40))))

;; if condition (if の条件式部分の展開)
(gcd (remainder 206 40)
     (remainder 40 (remainder 206 40)))

;; 3rd expand (3回目の展開)
;; remainder : 3 回使用(if の条件式部で 2回,現在 1回)
(if (= (remainder 40 (remainder 206 40)) 0) ; => (= (remainder 40 6) 0) => (= 4 0) => #f
    (remainder 206 40)
    (gcd (remainder 40 (remainder 206 40))
         (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))))

;; if condition (if の条件式の展開)
(gcd (remainder 40 (remainder 206 40))
     (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))

;; 4th expand (4回目の展開)
;; remainder : 7 回使用(if の条件式部で 4回,現在 3回)
(if (= (remainder (remainder 206 40) (remainder 40 (remainder 206 40))) 0) ; (= (remainder 6 (remainder 40 6)) 0) => (= (remainder 6 4) 0) => (= 2 0) => #f
    (remainder 40 (remainder 206 40))
    (gcd (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
         (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))))

;; if condition (if の条件式の展開)
(gcd (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
     (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))))

;; 5th expand (5回目の展開)
;; remainder : 14 回使用(if の条件式部で 7回,現在 7回)
(if (= (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))) 0) ; (= (remainder (remainder 40 6) (remainder 6 (remainder 40 6))) 0) => (= (remainder 4 (remainder 6 4)) 0) => (= (remainder 4 2) 0) => (= 0 0) => #t
    (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))
    (gcd (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40))))
         (remainder (remainder (remainder 206 40) (remainder 40 (remainder 206 40))) (remainder (remainder 40 (remainder 206 40)) (remainder (remainder 206 40) (remainder 40 (remainder 206 40)))))))

;; if condition (if の条件式の展開)
;; remainder : 18 回使用(全体で 4回,現在 14回)
(remainder (remainder 206 40) (remainder 40 (remainder 206 40)))

;; 計算1
(remainder 6 (remainder 40 6))

;; 計算2
(remainder 6 4)

;; 計算3
2

clairvyclairvy 2008/11/22 08:14 検証ありがとうございます.
何度も更新しているのが悪かったのでしょうかね.
もうちょっと待つが吉なのかも.

ゲスト



トラックバック - http://csnagoya-sicp.g.hatena.ne.jp/YasuyukiMiura/20081122