title: Implementing take using foldr
body: <p>This is my <code>take</code> version using <code>foldr</code>:</p>
  
  <pre><code>myTake n list = foldr step [] list
                  where step x y | (length y) &lt; n = x : y
                                 | otherwise = y
  
  main = do print $ myTake 2 [1,2,3,4]
  </code></pre>
  
  <p>The output is not what I expect:</p>
  
  <pre><code>[3,4]
  </code></pre>
  
  <p>I then tried to debug by inserting the length of <code>y</code> into itself and the result was:</p>
  
  <pre><code>[3,2,1,0]
  </code></pre>
  
  <p>I don't understand why the lengths are inserted in decreasing order. Perhaps something obvious I missed?</p>