I am trying to write a function that will combine 2 lists without using "divide and conquer". Therefore I cannot use (++).
Prelude> let combineList (x:xs) (y:ys) = if null (y:ys)==True then x:xs else combineList (x:xs++[y]) (ys)
This is what I have right now, and I get "Non-exhaustive patterns in function combineList". I realize that the problem comes from if null (y:ys)==True, because this function works -
Prelude> let combineList (x:xs) (y:ys) = if ys==[] then x:xs++[y] else combineList (x:xs++[y]) (ys)
but I'd like to get rid of the ++[y] in the output if possible.
Correction to the code is much appreciated.
combineListshould basically do what++does, but it shouldn't use++to achieve this?(++).(++) = flip (foldr (:))extensionally.