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.
12 lines
258 B
12 lines
258 B
5 years ago
|
-module(lookup).
|
||
|
|
||
|
-export([by_key/2]).
|
||
|
|
||
|
by_key(_, []) -> "unknown";
|
||
|
by_key(Key, [{Key, Val} | _]) -> Val;
|
||
|
by_key(Key, [_ | Tail]) -> by_key(Key, Tail).
|
||
|
|
||
|
% lookup:by_key(birthday, [{ice, "cream"}, {birthday, "cake"}]).
|
||
|
% equivalent to proplists:get_value/2_
|
||
|
|