[erlang-questions] guard sequence for string?

Mats Cronqvist <>
Tue Jan 30 09:09:43 CET 2007


jm wrote:
> Is there a guard sequence to test if a supplied parameter is a ascii 
> string, ie, is_string, the same as there is is_integer? I check the docs 
> and am unable to find anything. I tried is_list() but this doesn't seem 
> to do what I want (it was a long shot). So what's the stardard approach 
> here?

   variations on this theme, i'm afraid.

is_string([]) -> true;
is_string([H|T]) when integer(H), H >= $ , H =< $~ -> is_string(T);
is_string(_) -> false.



More information about the erlang-questions mailing list