[erlang-questions] guard sequence for string?

jm <>
Wed Jan 31 00:58:19 CET 2007

Mats Cronqvist wrote:
> 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.
> _______________________________________________

Thanks. I worked around it by re-ordering things in the mean time. The 
work around is not as reliable as as using a guard. When I looking back 
over that code again in the next few days I'll have to give this a try.


More information about the erlang-questions mailing list