[erlang-questions] Efficiency of a list construction
Pierpaolo Bernardi
olopierpa@REDACTED
Fri May 20 13:50:50 CEST 2011
On Fri, May 20, 2011 at 12:50, Vance Shipley <vances@REDACTED> wrote:
> Kannan,
>
> No, it is not tail recursive. This is:
>
> %% @spec() -> [term()]
> %%
> flush() ->
> flush([]).
>
> %% @hidden
> flush(Msgs) ->
> receive
> Msg ->
> flush([Msg | Msgs]);
> after 17 ->
> Msgs
> end.
However, this returns a reversed list, w.r.t.
> On Fri, May 20, 2011 at 03:45:19PM +0530, Kannan wrote:
> } Is the following list construction an efficient one?
> }
> } flush() ->
> } receive
> } Msg ->
> } [Msg|flush()]
> } after 17 ->
> } []
> } end.
P.
More information about the erlang-questions
mailing list