
1 Dec
2009
1 Dec
'09
11:14 p.m.
Hi Ted, Some tips:
invlist_negate [] = [0] invlist_negate (0:xs) = xs invlist_negate xs = 0:xs
You are doing this for generic Num instances, so 0 probably isn't the lower bound. Haskell has another type class for this: Bounded. Then you can use minBound instead of 0. Also the first line is just a special case of the last one. invlist_negate :: (Bounded a, Num a) => [a] -> [a] invlist_negate (minBound : xs) = xs invlist_negate xs = minBound : xs Try doing invlist_member together with a function invlist_notMember (just like there is notElem for lists), I think that would clean things up a bit. Keep on going, there's lots of fun ahead! greetings, Sjoerd -- Sjoerd Visscher sjoerd@w3future.com