Given a list of sequence of negative and positive numbers, how can I partition them into sequences of negative and positive numbers using foldr?
For example [1,2,3,-1,-2,-3,1,2,3] i will get [[1,2,3],[-1,-2,-3],[1,2,3]]
A few doubts
How do I know that the previous partition that I have already compared if of the same sign as the one I am comparing current?
How do I add the element to the list? I tried something like [x]:y but what I get was each element as a list and concatenated together, which is not the result.
What I have currently is this
foldr (\ x y -> if x >= 0 then [x]:y else y ) [[]]
which is wrong
Many thanks for the help in advance.