title: Haskell - separate a list of pairs in two lists using fold
body: <p>So, I am given a list containing tuples and I need to break it down into two lists, the first list containing the elements with odd index and the second list containing the elements with even index, must be done using fold, here is my attempt:</p>
  
  <pre><code>breakList :: [(Integer, Integer)] -&gt; [[(Integer, Integer)]]
  breakList [] = [[], []]
  breakList xxs@(x:xs) = foldl (\ acc y -&gt; if length (acc !! 0) &lt; length (acc !! 1) then y : (acc !! 0) else y : (acc !! 1)  )  [[], []] xxs
  </code></pre>
  
  <p>Error I am getting:</p>
  
  <p><strong>Couldn't match type '(Integer, Integer)'
   with '[(Integer, Integer)]'
        Expected type: [[(Integer, Integer)]]</strong></p>
  
  <p>when hovering over <code>y : (acc !! 1) and y : (acc !! 0)</code></p>
  
  <p>Example:</p>
  
  <p>Input:</p>
  
  <blockquote>
    <p>ex1 = [ (2, 2), (1, 3), (2, 3), (2, 4), (3, 5), (0, 2), (2, 1), (1, 4)
    , (2, 0), (1, 2), (3, 1), (1, 0)]</p>
  </blockquote>
  
  <p>Output</p>
  
  <blockquote>
    <p>breakList ex1 
    ==  ( [(2,2),(2,3),(3,5),(2,1),(2,0),(3,1)] , [(1,3),(2,4),(0,2),(1,4),(1,2),(1,0)])</p>
  </blockquote>