I\'ve been reading Erlang and OTP in action, and stumbled upon a question with regards to improper lists.
Don’t be tempted to use list cel
One valid use is described at the very bottom of the Eunit user manual, in the section about lazy generators. This code example is supposed to create a very long list that will be consumed one element at a time, so instead of generating the entire list at once it creates an improper list whose tail describes how to generate the rest of the list:
lazy_test_() ->
lazy_gen(10000).
lazy_gen(N) ->
{generator,
fun () ->
if N > 0 ->
[?_test(...)
| lazy_gen(N-1)];
true ->
[]
end
end}.
In other words, it's a lazy list, which Erlang itself doesn't give you.