~statianzo/sevenlangs

ref: c1ca0d5093c035aac6fcd1323f054151ce5144ad sevenlangs/erlang/lookup.erl -rw-r--r-- 258 bytes
c1ca0d50Jason Staten more erlang exercises 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
-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_