作业帮 > 综合 > 作业

编程 haskell

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/04/28 14:28:29
编程 haskell
编程 haskell
data Prop = Const Bool
            | Var Char
            | Not Prop
            | And Prop Prop
            | Or Prop Prop
            | Imply Prop Prop
            deriving Eq
                          
instance Show Prop where
    show (Const a) = "Const " ++ show a
    show (Var a) = show a
    show (And a b) = show a ++ " && " ++ show b
    show (Or a b) = show a ++ " || " ++ show b
    show (Not a) = "!(" ++ show a ++ ")"
    show (Imply a b) = show a ++ " => " ++ show b

试试看吧
再问: 不能把'A' 的' '去掉么。。