[erlang-questions] Simple Erlang Recommendation (last returned value)

Thomas Lindgren thomasl_erlang@REDACTED
Fri Jul 25 21:35:26 CEST 2008


--- On Fri, 7/25/08, Berlin Brown <berlin.brown@REDACTED> wrote:
> I wish there were something like this to get the result of
> the last call
> 
> queue:new(),
> queue:add(joe,  erlang:last_value()),
> queue:add(mike, erlang:last_value())), ...

It's probably better to get more familiar with functional programming, which instead of updating state passes around values.

How about this?

lists:foldl(
   fun(X, Last_value) -> queue:add(X, Last_value) end,
   queue:new(),
   [joe, mike]).

Best,
Thomas


      



More information about the erlang-questions mailing list