title: Lambdas and Folds (Left and Right)
body: <p>I really don't understand code </p>
  
  <pre><code>myReverse'' :: [a] -&gt; [a]
  myReverse'' xs = foldr (\x fId empty -&gt; fId (x : empty)) id xs []
  </code></pre>
  
  <p>In case: </p>
  
  <ul>
  <li>empty mapping to [] &lt;---- accumulator </li>
  <li>id mapping to fID (func id) </li>
  <li>x is first element of xs (list) <br></li>
  </ul>
  
  <p>Can i sort/change the postion of agruments "id xs []" ? </p>
  
  <pre><code>myReverse'' xs = foldr (\x fId empty -&gt; fId (x : empty)) xs id []
  </code></pre>
  
  <p>I have read a book yesterday <a href="http://learnyouahaskell.com/higher-order-functions#lambdas" rel="nofollow">http://learnyouahaskell.com/higher-order-functions#lambdas</a></p>
  
  <pre><code>elem' :: (Eq a) =&gt; a -&gt; [a] -&gt; Bool  
  elem' y ys = foldl (\acc x -&gt; if x == y then True else acc) False ys  
  </code></pre>
  
  <p>The explanation is understandable to me. </p>
  
  <blockquote>
    <p>the left fold's binary function has the accumulator as the first parameter and the current value as the second one (so \acc x -> ...)</p>
  </blockquote>
  
  <p>or I can write as</p>
  
  <pre><code>elem' :: (Eq a) =&gt; a -&gt; [a] -&gt; Bool
  elem' y ys = foldr (\x acc -&gt; if x == y then True else acc) False ys
  </code></pre>
  
  <p>Anyone, can help/guide/explain me ? <br> 
  Many thanks!</p>