title: Implementation of inits using foldr
body: <p>I have to implement inits via foldr using map. I got most of it, however I'm missing the empty list element in my result list.</p>
  
  <pre><code>inits :: [a] -&gt; [[a]]
  inits = foldr ( \ x y -&gt; [x] : (map (x:) y) ) []
  </code></pre>
  
  <p>When called this results in:</p>
  
  <blockquote>
    <p>*Blueprint&lt; inits [1,2,3]</p>
    
    <p>[[1],[1,2],[1,2,3]]</p>
  </blockquote>
  
  <p>I am a bit stuck now and would be glad if someone could point me in the general direction of my error.</p>
  
  <p>Thanks in advance</p>
  
  <p>Solved:</p>
  
  <pre><code>inits :: [a] -&gt; [[a]]
  inits = foldr ( \ x y -&gt; [] : (map (x:) y) ) [[]]
  </code></pre>