JaLC IRDB Crossref DataCite NDL NDL-Digital RUDA JDCat NINJAL CiNii Articles CiNii Books CiNii Dissertations DBpedia Nikkei BP KAKEN Integbio MDR PubMed LSDB Archive 極地研ADS 極地研学術DB 公共データカタログ ムーンショット型研究開発事業
Y combinator You are encouraged to solve this task according to the task description, using any language you may know. In strict functional programming and the lambda calculus, functions (lambda expressions) don't have state and are only allowed to refer to arguments of enclosing functions. This rules out the usual definition of a recursive function wherein a function is associated with the state
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
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く