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

Bob Ippolito bob@REDACTED
Fri Jul 25 19:21:54 CEST 2008


On Fri, Jul 25, 2008 at 9:53 AM, Berlin Brown <berlin.brown@REDACTED> wrote:
>
>
> 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.

And an equivalent to Perl's $_ doesn't?

-bob



More information about the erlang-questions mailing list