Fakultas Ilmu Komputer UI

Commit b3881fba authored by Ari Nugraha's avatar Ari Nugraha
Browse files

implement multiplication

parent 70baa60a
...@@ -53,20 +53,20 @@ keyword :: String -> Parser () ...@@ -53,20 +53,20 @@ keyword :: String -> Parser ()
keyword = void . lexeme . string keyword = void . lexeme . string
doOperation "" = "" doOperation "" = ""
doOperation (x:'+':y:xs) = ubahKeChurch x ++ ubahKeChurch '+' ++ ubahKeChurch y ++ doOperation xs doOperation (x:'*':y:xs) = ubahKeChurch '*' ++ ubahKeChurch x ++ ubahKeChurch y ++ doOperation xs
doOperation (x:xs) = ubahKeChurch x ++ doOperation xs 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))"
ubahKeChurch '0' = "(\\s z. z)" ubahKeChurch '0' = "(\\s z . z)"
ubahKeChurch '1' = "(\\s z. s z)" ubahKeChurch '1' = "(\\s z . s z)"
ubahKeChurch '2' = "(\\s z. s (s z))" ubahKeChurch '2' = "(\\s z . s (s z))"
ubahKeChurch '3' = "(\\s z. s (s (s z)))" ubahKeChurch '3' = "(\\s z . s (s (s z)))"
ubahKeChurch '4' = "(\\s z. s (s (s (s z))))" ubahKeChurch '4' = "(\\s z . s (s (s (s z))))"
ubahKeChurch '5' = "(\\s z. s (s (s (s (s z)))))" ubahKeChurch '5' = "(\\s z . s (s (s (s (s z)))))"
ubahKeChurch '6' = "(\\s z. s (s (s (s (s (s z))))))" ubahKeChurch '6' = "(\\s z . s (s (s (s (s (s z))))))"
ubahKeChurch '7' = "(\\s z. s (s (s (s (s (s (s z)))))))" ubahKeChurch '7' = "(\\s z . s (s (s (s (s (s (s z)))))))"
ubahKeChurch '8' = "(\\s z. s (s (s (s (s (s (s (s z))))))))" ubahKeChurch '8' = "(\\s z . s (s (s (s (s (s (s (s z))))))))"
ubahKeChurch '9' = "(\\s z. s (s (s (s (s (s (s (s (s z)))))))))" ubahKeChurch '9' = "(\\s z . s (s (s (s (s (s (s (s (s z)))))))))"
ubahKeChurch x = [x] ubahKeChurch x = [x]
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