
3 Nov
2010
3 Nov
'10
6:31 p.m.
Hi, I'm having trouble with this small exercise. A function maybeA takes a list of pairs. A pair has a variable 'a' and a value 'b'. If any first element of a pair equals to any first element of another pair, the function returns Nothing. If they aren't equal, the function returns a tuple containing the first variable, its value and the value of the second variable. maybeA :: [(a,b)] -> Maybe (a,b,b) For example: [(a1,b1),(a2,b2),(a3,b3)..] returns Nothing if a2 = a3 and returns Just (a2,b2,b3) if a2 /= a3 I'm currently have :maybeA [(a1,b1),(a2,b2)] |a1 == a2 = Nothing |a1 /= a2 = Just (x1,y1,y2) but it only takes 2 pairs. Any helps? Thanks