4 ms·
The Erlang version is unnecessarily verbose (and also semantically different) because it uses 2 processes. It can be rewritten as Foo = fun(N) -> put(var, N),
by yariv 19y ago
The Erlang version is unnecessarily verbose (and also semantically different) because it uses 2 processes. It can be rewritten as
Foo = fun(N) -> put(var, N), fun(X) -> V = get(var) + X, put(var, V), V end end.
It's not as concise as Ruby or Arc, but it's a one liner. However, similar to Haskell, this style of programming is discouraged in Erlang.