Here's how I wrote the Haskell splitAt function:splitAt' :: Int -> [a] -> ([a], [a])splitAt' n ys       | n < 0     = ([], ys)      | otherwise = splitAt'' n ys []      where splitAt'' a (x:xs) acc                  | a == 0 = (acc, x:xs)                  | null xs = (acc ++ [x], [])                  | otherwise = splitAt'' (a-1) xs (acc ++ [x])I don't like I'm using the append (++) function to add an element to the end of my acc(umulator).But, given the importance of ordering, I'm not sure how to avoid using it.Please review this code as well.
Haskell#splitAt
haskell;reinventing the wheel
You should be able to implement it without ++.splitAt' :: Int -> [a] -> ([a], [a])splitAt' 0 ys     = ([], ys)splitAt' _ []     = ([], [])splitAt' n (y:ys)  | n < 0     = ([], (y:ys))  | otherwise = ((y:a), b)  where (a, b) = splitAt' (n - 1) ys