I cannot use high order functions. I just can't figure out how to do this. I am very new to haskell. It must also be recursive.
split :: [Int] -> ([Int],[Int])
split xs =
It is given to me to begin with. I honestly don’t even know where to start 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 greatly appreciated.
Edit: even and odd positions.
So,
the split [3,6,8,9,10] will be ([3,8,10], [6,9])
OK, so I came up with this. This is not very, but it seems that everything is fine.
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)))