Arantium Maestum

プログラミング、囲碁、読書の話題

2016-06-06から1日間の記事一覧

SICPの勉強 Lecture 2B-2

www.youtube.com あと、この講義の終わりの方でcons-cellをclosureのみで作るコードが提示される。cons-cellがあればlinked listが作れて、複雑なデータ構造を組み上げていくことができる(遅いので実装上は使わないが)。データ構造すら、closureを持つproc…

SICPの勉強 Lecture 2B-1

www.youtube.com 37:40からの質問への答えがすごい。 Q: What does this "delayed decision through abstraction layers" do to the maxim of "do your design before any of your code"? A: Well that's someone's axiom, and I bet that's the axiom of so…

SICPの勉強 問題1.46

SICP1.3.4の問題1.46を解いてみる。 iterative-improveの定義。これは再帰で書くのがすごくしっくりくる。 (defn iterative-improve [good-enough? improve] (fn [guess] (if (good-enough? guess) guess (recur (improve guess))))) iterative-improveを使…

SICPの勉強 問題1.45

SICP1.3.4の問題1.45を解いてみる。 average-dampとfixed-pointを使って任意のx、nにおけるxのn乗根の開方を求める。 average-dampを一回かけるだけの場合、y -> x/y3までは大丈夫だが y -> x/y4だと収束しない。 とりあえずaverage-dampを任意の回数繰り返…

SICPの勉強 問題1.41~44

SICP1.3.4の問題1.41、42、43そして44を解いてみる。 1.41問 引数1の関数を取り、その関数を倍掛けするdouble関数: (defn double [f] (fn [x] (f (f x)))) 問題文に出てくる(((double (double double)) inc) 5)について、パッと見だと5+8で13かな?と思っ…