2 ms·
> PS: Having only dabbled in Erlang, to me the real problem exposed by those examples is the lack of a combined lambda/case, All lambda in Erlang is case:
by geocar 10y ago
> PS: Having only dabbled in Erlang, to me the real problem exposed by those examples is the lack of a combined lambda/case,
All lambda in Erlang is case:
do_whatever(Keys, SomeParameter) ->
Lookups = lists:map(fun external_lookup/1, Keys),
lists:foreach(fun
({ok, V}) -> do_side_effecty_thing(V, SomeParameter);
({error, R}) -> report_some_failure(R)
end, Lookups).
- chriswarbo 10y agoAh, sorry you're right; I mustn't have played with Erlang enough to fade out the punctuation (unlike Lisp, where https://github.com/tarsius/paren-face https://github.com/tarsius/paren-face can do it for me ;) ).
- strmpnk 10y agoI came away with a similar reaction, but there is no need to map separately first: https://news.ycombinator.com/item?id=13136056 https://news.ycombinator.com/item?id=13136056 Sometimes I do wish Erlang had something like F#'s active patterns because it'd make this sort of thing trivial to add to standard pattern expressions. Maybe someday I'll figure out how to add it myself.