トップ «前の日記(2011-05-09(Mon)) 最新 次の日記(2011-05-18(Wed))» 編集

屑俺日記

僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。


2011-05-15(Sun) そろそろ夜明けだ。晴れるといいかも

高階級数

前にPython でそんな感じのがあった気がするが、 それはまた考えよう。
まず fold。組み込みの関数だそうである。 まる写しでこんな感じである。
このあたりは(多分、まだ)自分の頭ではどうにも。

(define (fold proc init lis)
  (if (null? lis)
   init
   (fold proc (proc (car lis) init) (cdr lis))))
(fold cons '() 'a b c d e)
(e d c b a)
#?=(fold cons '() '(a b c d e))
#?="(stdin)":14:(fold cons '() '(a b c d e))
#?="(stdin)":4:(cdr lis)
#?-    (b c d e)
#?="(stdin)":4:(cdr lis)
#?-    (c d e)
#?="(stdin)":4:(cdr lis)
#?-    (d e)
#?="(stdin)":4:(cdr lis)
#?-    (e)
#?="(stdin)":4:(cdr lis)
#?-    ()
#?-    (e d c b a)
(e d c b a)

...分かったような分からないような


リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。

index.htmlは ここから。