<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>My understanding is that foldl is preferred over foldr because it is tail recursive. I was also to understand that putting the accumulator on the left-hand-side of the ++ operation is super bad.</div>

</blockquote><div><br></div><div><div>According to Erlang and OTP in Action, the cost of ++ is specified by the left side. ++ copies the items on the left side on top of the right side which explains the performance difference. If the order does not matter, always put the smaller list on the left side.<br>

</div><div><br></div><span style="font-size:13px;font-family:arial,sans-serif;border-collapse:collapse"><b><span style="border-collapse:separate;font-family:arial;font-weight:normal"><div><span style="font-family:arial,sans-serif;border-collapse:collapse"><b>José Valim</b></span></div>

<div><span style="font-family:arial,sans-serif;border-collapse:collapse"><div><span style="font-family:verdana,sans-serif;font-size:x-small"><a href="http://www.plataformatec.com.br/" target="_blank" style="color:rgb(42,93,176)">www.plataformatec.com.br</a></span></div>

<div><span style="font-family:verdana,sans-serif;font-size:x-small">Founder and Lead Developer</span></div></span></div></span></b></span></div></div>