title: haskell foldr manipulation with lists
body: <p>Given a list of sequence of negative and positive numbers, how can I partition them into sequences of negative and positive numbers using foldr?</p>
  
  <p>For example [1,2,3,-1,-2,-3,1,2,3] i will get [[1,2,3],[-1,-2,-3],[1,2,3]]</p>
  
  <p>A few doubts</p>
  
  <p>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?</p>
  
  <p>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.</p>
  
  <p>What I have currently is this</p>
  
  <pre><code>foldr (\ x y -&gt; if  x &gt;= 0  then [x]:y else y ) [[]] 
  </code></pre>
  
  <p>which is wrong</p>
  
  <p>Many thanks for the help in advance.</p>