
12 Jul
2011
12 Jul
'11
8:06 a.m.
I am not sure where your error is coming from. module Main where halve :: [a] -> ([a],[a]) halve xs | null xs = ([],[]) | otherwise = (take r xs, drop s xs) where (p,q) = divMod (length xs) 2 (r,s) = if q == 0 then (p,p) else (p + 1,p) works fine for me in ghci and is approximately what you wrote :) For what it's worth your implementation has a bug in it, you only want to take an extra item in the odd case. Ben