Drkcore

20 04 2007 SICP Emacs Tweet

elispで平方根

相変わらずSICPをelispで

ProductName 計算機プログラムの構造と解釈
ジェラルド・ジェイ サスマン
ピアソンエデュケーション / 4830円 ( 2000-02 )


(defun goodenough (guess x)(< (abs (- (* guess guess) x)) 0.001))
(defun improve (guess x) (average guess (/ x guess)))
(defun average (x y) (/ (+ x y) 2))
(defun sqlt_it (guess x)
 (if (goodenough guess x)
      guess
    (sqlt_it (improve guess x) x)))

(sqlt_it 1.0 5)
2.2360688956433634

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021