関数型言語の勉強にSICPを読もう - (6) 1章 - 小休止 traceを使えるようにする
dankogaiさんからトラックバック404 Blog Not Found:scheme - traceとslibで助け舟を頂いた。
このように、「知らないとなかなかたどり着けない情報」をご提供いただけることはとても幸せなことだと思います。
slibとtraceの準備
Ubuntuならこんな感じ。
apt-get install slib
goshで requireしてみると・・・。
gosh> (use slib)
#<undef>
gosh> (require 'trace)
*** ERROR: couldn't open output file: "/usr/share/gauche/0.8.4/lib/slibcat"
Stack Trace:
_______________________________________
0 (call-with-output-file catpath (lambda (op) (define (display* . ar ...
At line 22 of "/usr/share/slib/mklibcat"
1 (cons <pathname> extra)
At line 76 of "/usr/share/slib/require.scm"
2 (slib:load (in-vicinity (library-vicinity) "mklibcat"))
At line 141 of "/usr/share/slib/require.scm"
3 (catalog:get feature)
At line 200 of "/usr/share/slib/require.scm"エラーになります。
Gauche:FAQに解決方法が書いてありました。
要はroot権限でuseとrequireを一度実行すればその後は問題なく使えるようになるようです。
traceの使い方
実行をtraceしたい関数の名前を指定して、次にその関数を実行するだけです。
gosh >(trace f) gosh > (f (list 1 2 3))
これを利用して再帰と反復の違いを理解しようという記事を明日書こうと思います。
計算機プログラムの構造と解釈
posted with amazlet on 06.04.15
Gerald Jay Sussman Julie Sussman Harold Abelson 和田 英一
ピアソンエデュケーション (2000/02)
売り上げランキング: 56,404
ピアソンエデュケーション (2000/02)
売り上げランキング: 56,404
