嗨,我目前正在尝试使用 eleem 函数的前奏。
data MyType = A Int
| B Int Int
| C Int
| D Int Int
deriving (Show,Eq)
list = [ A _, B _ _ ]
或
list = [ A Int, B Int Int ]
bool = (A 12) elem list -- use like this to get a Boolean value.
The problem is the list, it will (both) have compile err或. Can someone tell me the right way to define list?
Oops about the data and deriving (Show,Eq) in my main code I did do all that. The reason f或 this question is that I have a big list of MyType and I want to cherry pick one 或 two of the types out of the big list modify it then put it back, how do I do that? Exp. bigList=[ A 3, C 6, A 5, B 5 8, D 5 6 ] I would like to pick out only the data type ( A Int ) and (B Int Int) , maybe change all value f或 the two data type into 0, after modification put back so I end up with a new list. newBigList=[ A 0, C 6, A 0, B 0 0, D 5 6 ]
谢谢 谢谢