[erlang-questions] Erlang list comprehension optimization
Fri Mar 19 21:55:04 CET 2010
Just a small question.
'lc^0'([E|Tail], Expr) ->
'lc^0'(, _Expr) -> .
Where this name ('lc^0') is generated?
2010/3/17 Björn Gustavsson <>
> On Wed, Mar 17, 2010 at 5:07 AM, Robert Virding <>
> > There is one strange thing further up in the text:
> > "Lists comprehensions still have a reputation for being slow. They
> > used to be implemented using funs, which used to be slow."
> > List comprehensions have never been implemented with funs, at least
> > not when they were first introduced. I know.
> Have a look the function lc_tq/3 starting at line 430 in R6B:
> It seems clear to me from the code that list comprehensions are
> rewritten to an expression that uses a fun. Also see the comment
> before the function. It says that because Erlang doesn't have letrecs, the
> lambda (fun) is explicitly passed as an extra argument.
> Nowadays, list comprehensions are translated to letrecs
> (which are available in Core Erlang), and the letrecs are in
> turn translated to ordinary recursive functions.
> Björn Gustavsson, Erlang/OTP, Ericsson AB
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
More information about the erlang-questions