
26 Jul
2011
26 Jul
'11
5:25 a.m.
I have one suggestion:
sumCheck total (x:xs) ys = if total' == Nothing then sumCheck total xs ys else return (x, (ys !! ( fromJust total'))) where total' = (total - x) `elemIndex` ys
I might write this:
sumCheck total (x:xs) ys = let diff = total - x in if diff `elem` ys then Just (x, diff) else sumCheck total xs ys
Cheers, A