Is there an elegant guard test for strings?

Tony Hobbins Tony.Hobbins@REDACTED
Tue Aug 16 23:09:34 CEST 2005

Hi all,

I hope this question is not as stupid as it sounds.

What is the most elegant guard construct for testing for a string?

e.g. I want to be able to ...

foo(X) when is_string(X)->

where is_string() has the semantics of returning true for lists which
are simple strings .

I want to use this function in the following context

foo(X) when is_string(X)->

foo(X) when is_list(X)->
	lists:map(fun(Z)->foo(Z) end,X).

Any advice appreciated.



More information about the erlang-questions mailing list