diff --git a/src/otpbp_lists.erl b/src/otpbp_lists.erl index d4bc0c07..42021fc2 100644 --- a/src/otpbp_lists.erl +++ b/src/otpbp_lists.erl @@ -41,6 +41,17 @@ -export([zipwith3/5]). -endif. +-ifndef(HAVE_lists__enumerate_1). +-ifdef(HAVE_lists__enumerate_2). +-import(lists, [enumerate/2]). +-endif. +-endif. +-ifndef(HAVE_lists__enumerate_2). +-ifdef(HAVE_lists__enumerate_3). +-import(lists, [enumerate/3]). +-endif. +-endif. + -ifndef(HAVE_lists__search_2). search(F, [H|T]) -> case F(H) of @@ -51,15 +62,11 @@ search(F, []) when is_function(F, 1) -> false. -endif. -ifndef(HAVE_lists__enumerate_1). -enumerate(List) -> - {L, _} = lists:mapfoldl(fun(E, A) -> {{A, E}, A + 1} end, 1, List), - L. +enumerate(List) -> enumerate(1, List). -endif. -ifndef(HAVE_lists__enumerate_2). -enumerate(Index, List) when is_integer(Index) -> - {L, _} = lists:mapfoldl(fun(E, A) -> {{A, E}, A + 1} end, Index, List), - L. +enumerate(Index, List) -> enumerate(Index, 1, List). -endif. -ifndef(HAVE_lists__enumerate_3).