You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
309 B

-module(lookup).
-export([by_key/2]).
by_key(_, []) -> "unknown";
by_key(Key, [{Key, Val} | _]) -> Val;
by_key(Key, [_ | Tail]) -> by_key(Key, Tail);
by_key(Key, M) when is_map(M) -> maps:get(Key, M).
% lookup:by_key(birthday, [{ice, "cream"}, {birthday, "cake"}]).
% equivalent to proplists:get_value/2_