You probably don't want that minBound in the pattern, but rather as a
comparison in a guard.

Dan

On Tue, Dec 1, 2009 at 6:14 PM, Sjoerd Visscher <sjo...@w3future.com> wrote:
> 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
> sjo...@w3future.com
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to