[erlang-questions] Efficiency of a list construction

Vance Shipley <>
Fri May 20 12:50:46 CEST 2011


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.

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.

-- 
	-Vance



More information about the erlang-questions mailing list