2010/01/25

5の階乗

 

; 5の階乗
(((lambda (f)
    (f f))
  (lambda (f)
    (lambda (n)
      (cond ((zero? n) 1)
            (else (((lambda (f)
                      (f f))
                    (lambda (f)
                      (lambda (n m)
                        (cond ((zero? m) 0)
                              (else ((
(lambda (f)
                                        (f f))
                                      (lambda (f)
                                        (lambda (n m)
                                          (cond ((zero? m) n)
                                                (else ((lambda (n)(+ n 1)) ((f f) n ((lambda (n)(- n 1)) m))))))))

                                     n ((f f) n ((lambda (n)(- n 1)) m))))))))
                   n ((f f) ((lambda (n)(- n 1)) n)))))))) 5)

 

追記

-と+を間違えてたので修正


計算論 計算可能性とラムダ計算 (コンピュータサイエンス大学講座)The Little Schemer, 4th Edition

0 件のコメント:

コメントを投稿