
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

On Nov 11, 2007 6:37 AM, Ryan Bloor
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
| (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
participants (2)
-
Brent Yorgey
-
Ryan Bloor