This is a regular paragraph.
Piyo| Foo | Bar |
| Hoge |
This is a regular paragraph.
Piyo| Foo | Bar |
| Hoge |
| module Eval (run) where | |
| import Type | |
| import Infer | |
| import Control.Arrow | |
| import Debug.Trace | |
| ti a b = trace (a ++ show b) b | |
| t' a b = trace (a ++ show b) |
hoge
import Data.List
main = do
x <- getContents
print x
| {-# LANGUAGE TemplateHaskell, DeriveFunctor, DeriveFoldable #-} | |
| import Prelude hiding (foldr) | |
| import Data.Foldable | |
| import Data.Thorn | |
| data Rose a = Leaf | Rose a (Forest a) | |
| deriving (Functor, Show, Foldable) | |
| data Forest a = Forest [Rose a] |
型なしラムダ計算の実装を第一回の宿題とします.
変数名付きのラムダ項が String で与えられるので, 評価した上で名無し項を String で返す eval 関数を実装してください.
具体的には次のような関数になります:
eval "(\\x. \\y. x) (\\x. x)" -- -> "(\\ (\\ 0))" ひな形は Eval.hs です. Test.hs を実行することでテストできます.
成功した場合次のようになります:
| import Eval (eval) | |
| results = [eval "(\\x. x) (\\x. x)" == "(\\ 0)", | |
| eval "(\\x. x x) (\\x. \\y. x)" == "(\\ (\\ (\\ 1)))", | |
| eval "(\\p. p (\\t. \\f. t)) ((\\f. \\s. \\b. b f s) (\\x. x) (\\x. \\y. x))" == "(\\ 0)", | |
| eval "(\\x. \\y. \\z. x z (y z)) (\\x. \\y. x) (\\x. \\y. x) (\\x. \\y. x)" == "(\\ (\\ 1))", | |
| eval "(\\m. m (\\x. \\t. \\f. f) (\\t. \\f. t)) ((\\n. \\s. \\z. s (n s z)) (\\s. \\z. s z))" == "(\\ (\\ 0))"] | |
| main = do | |
| let xs = filter (not . snd) $ zip [0..] results :: [(Int, Bool)] | |
| if null xs then putStrLn "OK" |
| 1. transmission | |
| 2. smell | |
| 3. larva | |
| 4. epidemic | |
| 5. blood system | |
| 6. infection | |
| 7. drainage | |
| 8. mosquito | |
| 9. village | |
| 10. liver |