diff options
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r-- | src/gleam_stdlib.erl | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl index c06854a..5d83e9d 100644 --- a/src/gleam_stdlib.erl +++ b/src/gleam_stdlib.erl @@ -349,9 +349,9 @@ inspect(Binary) when is_binary(Binary) -> ["<<", lists:join(", ", Segments), ">>"] end; inspect(List) when is_list(List) -> - case inspect_list(firstCall, properList, List) of - {properList, Elements} -> ["[", Elements, "]"]; - {improperList, Elements} -> ["//erl[", Elements, "] %% improper list"] + case inspect_list(List) of + {proper, Elements} -> ["[", Elements, "]"]; + {improper, Elements} -> ["//erl[", Elements, "]"] end; inspect(Any) when is_tuple(Any) % Record constructors andalso is_atom(element(1, Any)) @@ -377,18 +377,16 @@ inspect(Any) when is_function(Any) -> inspect(Any) -> ["//erl(", io_lib:format("~p", [Any]), ")"]. -inspect_list(_recursionCount, properList, []) -> - {properList, []}; -inspect_list(firstCall, properList, [Head]) -> - {properList, [inspect(Head)]}; -inspect_list(firstCall, properList, [First | Rest]) -> - {ListKind, Elements} = inspect_list(nthCall, properList, Rest), - {ListKind, [inspect(First) | Elements]}; -inspect_list(nthCall, properList, [First | Rest]) -> - {ListKind, Elements} = inspect_list(nthCall, properList, Rest), - {ListKind, [<<", ">>, inspect(First) | Elements]}; -inspect_list(nthCall, properList, ImproperTail) -> - {improperList, [<<" | ">>, inspect(ImproperTail)]}. + +inspect_list([]) -> + {proper, []}; +inspect_list([Head]) -> + {proper, [inspect(Head)]}; +inspect_list([First | Rest]) when is_list(Rest) -> + {Kind, Inspected} = inspect_list(Rest), + {Kind, [inspect(First), <<", ">> | Inspected]}; +inspect_list([First | ImproperTail]) -> + {improper, [inspect(First), <<" | ">>, inspect(ImproperTail)]}. float_to_string(Float) when is_float(Float) -> erlang:iolist_to_binary(io_lib_format:fwrite_g(Float)). |