
hiya I was wondering how I would get the second function do recursively do the function for poolNews xs.... tried that and it fails. Ryan --Give wins, draws a rating. poolNews :: Result -> PoolNews -> PoolNews poolNews (a,b,c,d,e) (home,away,goaless,scoredraw) | c > d = (home+1,away,goaless,scoredraw) | c < d = (home,away+1,goaless,scoredraw) |(c == 0) && (d == 0) = (home+1,away,goaless+1,scoredraw) | otherwise = (home,away,goaless,scoredraw+1) --Do for all Results poolNewsB :: Results -> PoolNews poolNewsB (x:xs) = poolNews x (0,0,0,0) _________________________________________________________________ Celeb spotting – Play CelebMashup and win cool prizes https://www.celebmashup.com

Looks to me like you want:
poolNewsB = foldr poolNews (0,0,0,0)
On Nov 10, 2007 11:54 AM, Ryan Bloor
hiya
I was wondering how I would get the second function do recursively do the function for poolNews xs.... tried that and it fails.
Ryan
--Give wins, draws a rating.
poolNews :: Result -> PoolNews -> PoolNews
poolNews (a,b,c,d,e) (home,away,goaless,scoredraw)
| c > d = (home+1,away,goaless,scoredraw)
| c < d = (home,away+1,goaless,scoredraw)
|(c == 0) && (d == 0) = (home+1,away,goaless+1,scoredraw)
| otherwise = (home,away,goaless,scoredraw+1)
--Do for all Results
poolNewsB :: Results -> PoolNews poolNewsB (x:xs) = poolNews x (0,0,0,0)
________________________________ Get free emoticon packs and customisation from Windows Live. Pimp My Live! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Nov 10, 2007 11:54 AM, Ryan Bloor
hiya
I was wondering how I would get the second function do recursively do the function for poolNews xs.... tried that and it fails.
Ryan
--Give wins, draws a rating.
poolNews :: Result *->* PoolNews *->* PoolNews
poolNews (a,b,c,d,e) (home,away,goaless,scoredraw)
| c > d = (home+1,away,goaless,scoredraw)
| c < d = (home,away+1,goaless,scoredraw)
|(c == 0) && (d == 0) = (home+1,away,goaless+1,scoredraw)
| *otherwise* = (home,away,goaless,scoredraw+1)
--Do for all Results
poolNewsB :: Results *->* PoolNews poolNewsB (x:xs) = poolNews x (0,0,0,0)
As Andrew points out, really what you want is a fold. However, perhaps you're not supposed to use such Prelude functions in your assignment? The real issue here is that your definition of poolNewsB does not do anything with xs. You need to somehow incorportate a recursive call that will process the rest of the list (xs) as well as the first item (x). Hope that helps! -Brent
participants (3)
-
Andrew Wagner
-
Brent Yorgey
-
Ryan Bloor