From: Peter Lemenkov <lemenkov@gmail.com>
Date: Wed, 23 Aug 2017 13:15:37 +0300
Subject: [PATCH] Add missing f2l and l2f macros
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
diff --git a/include/prelude.hrl b/include/prelude.hrl
index 1c5581b..6ee0178 100644
--- a/include/prelude.hrl
+++ b/include/prelude.hrl
@@ -28,6 +28,8 @@
-define(l2b(X), erlang:list_to_binary(X)).
-define(b2t(X), erlang:binary_to_term(X)).
-define(t2b(X), erlang:term_to_binary(X)).
+-define(f2l(X), erlang:float_to_list(X)).
+-define(l2f(X), erlang:list_to_float(X)).
-define(i2l(X), erlang:integer_to_list(X)).
-define(l2i(X), erlang:list_to_integer(X)).
-define(i2b(X), erlang:integer_to_binary(X)).
diff --git a/src/s2_lists.erl b/src/s2_lists.erl
index b22a3f4..a1882d1 100644
--- a/src/s2_lists.erl
+++ b/src/s2_lists.erl
@@ -181,6 +181,7 @@ take_test() ->
%% @doc to_list(X) is the list-representation of X.
to_list(X) when is_atom(X) -> ?a2l(X);
to_list(X) when is_binary(X) -> ?b2l(X);
+to_list(X) when is_float(X) -> ?f2l(X);
to_list(X) when is_integer(X) -> ?i2l(X);
to_list(X) when is_list(X) -> X;
to_list(X) when is_pid(X) -> pid_to_list(X);
@@ -190,6 +191,7 @@ to_list_test() ->
"atom" = to_list(atom),
"bin" = to_list(<<"bin">>),
[] = to_list(<<>>),
+ "6.66000000000000000000e+02" = to_list(666.0),
"42" = to_list(42),
[] = to_list([]),
"<" ++ _ = to_list(self()),