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

Berlin Brown berlin.brown@REDACTED
Fri Jul 25 18:53:03 CEST 2008



On Jul 25, 12:36 pm, Tony Garnock-Jones <to...@REDACTED> wrote:
> Berlin Brown wrote:
> > NewQ = queue:new(),
> > Queue1 = queue:add(joe, NewQ),
> > Queue2 = queue:add(mike, Queue1), ...
>
> > queue:new(),
> > queue:add(joe,  erlang:last_value()),
> > queue:add(mike, erlang:last_value())), ...
>
> %% Untested.
> %% Use curried operations and a Haskell-like sequencing operator
> %% to provide a kind of dataflow/pipeline style.
>
> add(Elt) -> fun (Q) -> queue:add(Elt, Q) end.
>
> seq(X, []) -> X;
> seq(X, [F | Fs]) -> seq(F(X), Fs).
>
> test() ->
>    seq(queue:new(),
>        [add(joe),
>         add(mike)]).
>
> %% Quite major language (and library!) changes would be needed to
> %% make this feel properly natural.
>
> %% Tony
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions

These are great, but they look like hacks to me.



More information about the erlang-questions mailing list