[erlang-questions] lists bifs vs list comprehensions
Thu Apr 5 17:29:43 CEST 2012
On 04/05/12 17:45, Martin Dimitrov wrote:
> Several days ago I used the tidier tool on a module I wrote and I
> noticed that it translates lists:foreach/2 and lists:map/2 to list
> comprehensions. I did some tests and came to the conclusion that list
> comprehension is executed faster than lists:map/2. Also for lists less
> than 50 000 items lists:foreach/2 is again slower than list
> comprehension. But for bigger lists - it is the reverse.
A bit unrelated to your actual question, but AFAIK tidier does not
transform any lists:foreach/2 to a list comprehension. (If you have such
a case, I am definitely interested in seeing this.)
Instead it transforms lists:filter/2 to list comprehensions.
More information about the erlang-questions