<div dir="ltr">I tweaked your module to run via escript (just adding a simple main/1 and printing out the results of timer:tc), and I see a bit gap between foldl and foldr, whilst the hand coded version based on lists:reverse/1 is plenty fast enough:<br><br>t4@iske:test $ escript lr.beam 10000000<br>foldl: 679.103ms<br>foldr: 43609.149ms<br>reverse: 909.946ms<br>t4@iske:test $ evm info<br>R16B03 compiled for x86_64-apple-darwin11.4.2, 64bit <br><br>On Friday, 11 May 2012 10:27:29 UTC+1, Ulf Wiger  wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>On 11 May 2012, at 04:02, Richard O'Keefe wrote:
<br>
<br>> This can be written more efficiently, but it's best of all
<br>> just not to reverse the string in the first place.  Keep
<br>> the code at a level where you can see what's going on well
<br>> enough to spot the really _big_ efficiency gains.
<br>
<br>And this is of course the really important difference between
<br>foldr() and foldl():
<br>
<br>- in which order do you want to process the list?
<br>- if you build a list in the accumulator, in which order do you want it?
<br>
<br>For most practical purposes, one should assume that they 
<br>both both do their job efficiently.
<br>
<br>BR,
<br>Ulf
<br>
<br>Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
<br><a href="http://feuerlabs.com" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Ffeuerlabs.com\46sa\75D\46sntz\0751\46usg\75AFQjCNF0chXVMqB4H_x5Y8Cu-Zh9epB8sQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Ffeuerlabs.com\46sa\75D\46sntz\0751\46usg\75AFQjCNF0chXVMqB4H_x5Y8Cu-Zh9epB8sQ';return true;">http://feuerlabs.com</a>
<br>
<br>
<br>
<br>______________________________<wbr>_________________
<br>erlang-questions mailing list
<br><a href="javascript:" target="_blank" gdf-obfuscated-mailto="RCsAYeQVdOoJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">erlang-q...@erlang.org</a>
<br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Ferlang.org%2Fmailman%2Flistinfo%2Ferlang-questions\46sa\75D\46sntz\0751\46usg\75AFQjCNH15VBDH9qL9o1Zx3x6ZeLmwvUvTg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Ferlang.org%2Fmailman%2Flistinfo%2Ferlang-questions\46sa\75D\46sntz\0751\46usg\75AFQjCNH15VBDH9qL9o1Zx3x6ZeLmwvUvTg';return true;">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a>
<br></blockquote></div>