Created
October 4, 2015 22:37
-
-
Save Mine02C4/007371ac519e14a27bb5 to your computer and use it in GitHub Desktop.
情報論理学 10月5日 提出レポート
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| isBinaryOperator = flip elem ['*','+','>','='] | |
| isUnaryOperator = flip elem ['-'] | |
| prefixToInfix str | |
| | isBinaryOperator token = | |
| let left = prefixToInfix $ tail str | |
| right = prefixToInfix $ snd left | |
| in ("(" ++ fst left ++ [token] ++ fst right ++ ")", snd right) | |
| | isUnaryOperator token = | |
| let sub = prefixToInfix $ tail str | |
| in ("(" ++ [token] ++ fst sub ++ ")", snd sub) | |
| | otherwise = ([token], tail str) | |
| where token = head str | |
| main = do | |
| contents <- getContents | |
| putStr $ unlines $ map (fst . prefixToInfix) $ lines contents | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment