I can't use high order functions. I just can't see to figure out how to do this. I am very new to haskell. It also has to be recursive.
split :: [Int] -> ([Int],[Int])
split xs =
I am given this to start with. I honestly don't even know where to start with this problem.
Examples:
split []
([],[])
split [1]
([1],[])
split [1,2,3,4,5,6,7,8,9,10]
([1,3,5,7,9],[2,4,6,8,10])
any help would be much appreciated.
Edit: Its even and odd positions.
So
split [3,6,8,9,10] would be ([3,8,10],[6,9])
ok so i came up with this. Its not pretty, but it seems to work ok.
split :: [Int] -> ([Int],[Int])
split [] = ([],[])
split [xs] = ([xs],[])
split xs = (oddlist xs, evenlist xs)
oddlist :: [Int] -> ([Int])
oddlist xs | length xs <= 2 = [head(xs)]
| otherwise = [head(xs)] ++ oddlist(tail(tail(xs)))
evenlist :: [Int] -> ([Int])
evenlist xs | length xs <= 3 = [head(tail(xs))]
| otherwise = [head(tail(xs))] ++ evenlist(tail(tail(xs)))