[Haskell-cafe] missed clause???
Brent Yorgey
byorgey at gmail.com
Sun Nov 11 07:45:43 EST 2007
On Nov 11, 2007 6:37 AM, Ryan Bloor <ryanbloor at hotmail.com> wrote:
> hi
>
> I was testing my code when I came across a strange predicament. The input
> is a list of ints and a Results type which is of type
> [(int,.......),(Int......)......]. I am comparing each int from the list to
> the first element in each member of results. But it works for 1-9 but not
> for 10 onwards.... why?
> Have I missed a clause anywhere...... it only does the first one after
> that.
>
>
> --Print the points of eight games
>
> poolsPoints :: [Int]
> *->* Results *->* Int
>
> poolsPoints [] [] = 0
>
> poolsPoints [] _ = 0
>
> poolsPoints _ [] = 0
>
> poolsPoints (x:xs) ((a,b,c,d,e):t)
>
> | (x == a && c>d) = 1 + poolsPoints xs t
>
> | (x == a && c<d) = 1 + poolsPoints xs t
>
> | (x == a && c==0 && d==0) = 2 + poolsPoints xs t
>
> | (x == a && c==d && c>0) = 3 + poolsPoints xs t
> | *otherwise* = 0 + poolsPoints [x] t
>
That "poolsPoints [x] t" looks suspicious... are you sure that's what you
want? I don't actually know what your code is supposed to do, but it seems
odd to only pass along a list containing [x] in that case.
-Brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071111/fe720424/attachment.htm
More information about the Haskell-Cafe
mailing list