differentiate a string from a list in Erlang
using the isprint(3) definition of printable characters --
isprint(X) when X >= 32, X < 127 -> true;
isprint(_) -> false.
is_string(List) when is_list(List) -> lists:all(fun isprint/1, List);
is_string(_) -> false.
you won't be able to use it as a guard, though.
You have two functions in the module io_lib
which can be helpful: io_lib:printable_list/1
and io_lib:printable_unicode_list/1
which test if the argument is a list of printable latin1 or unicode characters respectively.