Fakultas Ilmu Komputer UI

Commit 568405b0 authored by Ari Nugraha's avatar Ari Nugraha
Browse files

implement for input number 0-9

parent e6fa7b6f
...@@ -9,7 +9,7 @@ import Text.Parsec.String ...@@ -9,7 +9,7 @@ import Text.Parsec.String
import Language.Lambda.Expression import Language.Lambda.Expression
parseExpr :: String -> Either ParseError (LambdaExpr String) parseExpr :: String -> Either ParseError (LambdaExpr String)
parseExpr = parse (whitespace *> expr <* eof) "" parseExpr kata = parse (whitespace *> expr <* eof) "" (doOperation kata)
expr :: Parser (LambdaExpr String) expr :: Parser (LambdaExpr String)
expr = try app <|> term expr = try app <|> term
...@@ -52,6 +52,9 @@ symbol = void . lexeme . char ...@@ -52,6 +52,9 @@ symbol = void . lexeme . char
keyword :: String -> Parser () keyword :: String -> Parser ()
keyword = void . lexeme . string keyword = void . lexeme . string
doOperation "" = ""
doOperation (x:xs) = ubahKeChurch x ++ doOperation xs
ubahKeChurch :: Char -> [Char] ubahKeChurch :: Char -> [Char]
ubahKeChurch '+' = "(\\w y x. y (w y x))" ubahKeChurch '+' = "(\\w y x. y (w y x))"
ubahKeChurch '*' = "(\\x y z . x (y z))" ubahKeChurch '*' = "(\\x y z . x (y z))"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment