I'm a new to haskell, I'm trying to create a function that will take a list on integers and returns a list containing two sublists, the first sublist containing the even number and the other containing the odd numbers. I cannot use even, odd or filter functions. i created my own functions as follows
myodd :: Integer -> Bool
myodd n = rem (abs(n)) 2 == 1
myeven :: Integer -> Bool
myeven n = rem (abs(n)) 2 == 0
segregate [] = ([], [])
segregate [x] = ([x], [])
segregate (x:y:xs) = (x:xp, y:yp) where (xp, yp) = segregate xs
im having trouble trying to use the two first functions and use it on the segregated functions. I have more experience in racket and the function I crated looks like this:
(define (myeven? x)
(= (modulo x 2) 0))
(define (myodd? x)
(= (modulo x 2) 1))
(define (segregate xs)
(foldr (lambda (x b)
(if (myeven? x)
(list (cons x (first b)) (second b))
(list (first b) (cons x (second b))))) '(()()) xs))