title: Split list and make sum from sublist?
body: <p>im searching for a solution for my Haskell class.</p>
  
  <p>I have a list of numbers and i need to return SUM for every part of list. Parts are divided by 0. I need to use FOLDL function.</p>
  
  <p>Example:<br>
  initial list: [1,2,3,0,3,4,0,5,2,1]<br>
  sublist [[1,2,3],[3,4],[5,2,1]]<br>
  result [6,7,7]</p>
  
  <p>I have a function for finding 0 in initial list:</p>
  
  <pre><code>findPos list = [index+1 | (index, e) &lt;- zip [0..] list, e == 0] 
  </code></pre>
  
  <p>(returns [4,6] for initial list from example) </p>
  
  <p>and function for making SUM with FOLDL:</p>
  
  <pre><code>sumList list = foldl (+) 0 list
  </code></pre>
  
  <p>But I completely failed to put it together :/</p>
  
  <p>---- MY SOLUTION <br>
  In the end I found something completely different that you guys suggested. <br>
  Took me whole day to make it :/</p>
  
  <pre><code>groups :: [Int] -&gt; [Int]
  groups list = [sum x | x &lt;- makelist list]
  
  makelist :: [Int] -&gt; [[Int]]
  makelist xs = reverse (foldl (\acc x -&gt; zero x acc) [[]] xs)  
  
  zero :: Int -&gt; [[Int]] -&gt; [[Int]]
  zero x acc | x == 0 = addnewtolist acc
             | otherwise = addtolist x acc
  
  addtolist :: Int -&gt; [[Int]] -&gt; [[Int]]
  addtolist i listlist = (i : (head listlist)) : (drop 1 listlist)
  
  addnewtolist :: [[Int]] -&gt; [[Int]]
  addnewtolist listlist = [] : listlist
  </code></pre>