Skip to content

Instantly share code, notes, and snippets.

@yingtai
Last active December 28, 2015 18:49
Show Gist options
  • Save yingtai/7545515 to your computer and use it in GitHub Desktop.
Save yingtai/7545515 to your computer and use it in GitHub Desktop.

型なしラムダ計算の実装を第一回の宿題とします.
変数名付きのラムダ項が String で与えられるので, 評価した上で名無し項を String で返す eval 関数を実装してください.
具体的には次のような関数になります:

eval "(\\x. \\y. x) (\\x. x)" -- -> "(\\ (\\ 0))" 

ひな形は Eval.hs です. Test.hs を実行することでテストできます.
成功した場合次のようになります:

> runghc Test.hs

run
- returns (\ 0) at the 1st case
- returns (\ (\ (\ 1))) at the 2nd case
- returns (\ 0) at the 3rd case
- returns (\ (\ 1)) at the 4th case
- returns (\ (\ 0)) at the 5th case

Finished in 0.0014 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment