1
2
3
4
5
6
7
8
9
10
11
12
13
|
-module(lists2).
-vsn(2).
-export([assoc/2, multi_map/2]).
assoc(Key, [{Key, Val} | _]) -> {ok, Val};
assoc(Key, [H | T]) -> assoc(Key, T);
assoc(Key, []) -> false.
multi_map(Func, [[] | ListOfLists]) -> [];
multi_map(Func, ListOfLists) ->
[apply(Func, lists:map({erlang, hd}, ListOfLists)) |
multi_map(Func, lists:map({erlang, tl}, ListOfLists))].
|