Church encodings, the U combinator and the Y combinator in JavaScript The lambda-calculus is almost too small to be a Turing-complete language. Almost. Because it is Turing-complete. With just three expression forms -- variable references, function application and anonymous functions -- it is possible to express arbitrary computation. These core forms exist as a subset of many popular programming
Haskell では、Y コンビネータが作れないと誤解している人がいるので、できることを示すと同時に、これまで学んだことをまとめてみます。 遅延評価を活かした Y コンビネータ 関数名を用いた再帰を使ってよいなら、Haskell では遅延評価のおかげで、Y コンビネータを定義である Y x = x (Y x) の通りに書けます。 y :: (a -> a) -> a y x = x (y x) Y コンビネータ用の階乗を定義してみましょう。 fact :: Num a => (a -> a) -> a -> a fact = \f n -> if n == 0 then 1 else n * f (n-1) 以下のように動きます。 y fact 4 → 24 でも、この階乗は Haskell っぽくないので、入り口で分岐するように書き直してみます。 fact :: Num a => (a
Simplest poly-variadic fixpoint combinators for mutual recursion Many ways to write the fixed-point combinator in a typed practical language Self-application and recursion: the U combinator Fixpoint combinators are infinitely many and recursively-enumerable Y overriding self-application: Y in practical programs Self-application as the fixpoint of call/cc Self-quoting fixpoints: Quines, in Scheme a
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く