I am trying to separate elements of a list into to further lists, one for the odd and one for even numbers.
input: [1,2,3,4,10] output: ([2,4,10],[1,3]) sepList :: [Int]->([Int],[Int]) sepList  = (,) sepList (x:xs) | (x mod 2) ==0 = (([x],) ++ sepList xs) | (x mod 2) /=0 = ((,[x]) ++ sepList xs) | otherwise = (,)
It gives error on
...++ sepList xs anyone could guide me here?
++ is used to concatenate 2 lists and neither of your arguments to
++ is a list,
([x],) ++ sepList xs
sepList xs are pairs of lists. So what you want is to pattern match on
sepList xs e.g. using a
let (ys,zs) = sepList xs in
and then return,