title: How can I write reverse by foldr efficiently in Haskell?
body: <p>Note that the trivial solution</p>
  
  <pre><code>reverse a = foldr (\b c -&gt; c ++ [b] ) [] a
  </code></pre>
  
  <p>is not very efficient, because of the quadratic growth in complexity. If have tried to use the usual foldl to foldr conversion (blindly), but my attempt</p>
  
  <pre><code>foldr (\b g x -&gt; g ((\x old -&gt; x:old) x b)) id list []
  </code></pre>
  
  <p>did not work as I expected.</p>