我對Haskell非常感興趣,並且正在嘗試解決這個問題。結合列表
爲了解決這個問題,必須由A匹配輸出列表C(X,Z)(X,Y)和由B(Y,Z)(無重複)的問題y必須是在甲等於和B.
因此,例如:
A = [("z","x")]
B = [("x","c"), ("x","d")]
結果:
C = [("z","c"), ("z","d")]
任何想法?我今天開始用:
main = print(map describeList3 list_A)
describeList3 :: ([Char], [Char]) ->Maybe [[Char]]
describeList3 element = printParam(snd element)
printParam :: String -> Maybe [[Char]]
printParam param = (Map.lookup param $ myFilter list_B)
myFilter :: (Ord k) => [(k, a)] -> Map.Map k [a]
myFilter xs = Map.fromListWith (++) $ map (\(k,v) -> (k,[v])) xs
目前卡住了...幫助?
如果這是家庭作業,最好爲它添加標籤'homework'。 – Ashe 2010-11-07 10:17:15
@Arlen:[「作業標籤與其他所謂的'meta'標籤一樣,現在不鼓勵。]](http://meta.stackexchange.com/q/10812) – 2010-11-07 23:39:40
@Roger:謝謝!我錯過了那個備忘錄,只能看到它(另外!)在別處的另一個問題上,並認爲它一定是最好的做法。 – Ashe 2010-11-08 04:45:13