Комбинаторы — это просто!: различия между версиями
Содержимое удалено Содержимое добавлено
Исправления к модулю на Haskell |
|||
Строка 320:
<code>data Combinator = Var String
| App Combinator Combinator
| Lam String Combinator
deriving Eq</code>
Строка 341:
<code>instance Show Combinator where
show (Var x) = x
show (App x y) =
case y of App _ _ -> showLam x ++ "(" ++ show y ++ ")"
_ -> showLam x ++ showLam y
where showLam l@(Lam _ _) = "(" ++ show l ++ ")"
showLam x = show x
show (Lam x e) = "\\" ++ x ++ "." ++ show e</code>
Строка 367 ⟶ 368 :
определяется так:
<code>free ::
Всё в полном соответствии с математическим определением.
Строка 383 ⟶ 384 :
<code>transform :: Combinator -> Combinator
(transform y)
(transform (Lam x e2))</code>
Видно, что определение этой функции полностью совпадает с описанием
|