编程 haskell
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/07/22 12:16:29
编程 haskell
![](http://img.wesiedu.com/upload/4/aa/4aa312996125d66ba8b421bc1818057c.jpg)
![](http://img.wesiedu.com/upload/4/aa/4aa312996125d66ba8b421bc1818057c.jpg)
![编程 haskell](/uploads/image/z/18434296-64-6.jpg?t=%E7%BC%96%E7%A8%8B+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' 的' '去掉么。。
| 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' 的' '去掉么。。