<div dir="ltr">A string is a list of integers [$F, $T] (where $x is a code for the letter x and so on)<div>A list of strings is a — List of lists of integers. That is [ [$F, $T], [$S, $T] ]</div><div>So to check whether a value is a list of lists you take its first element and check whether it's also a list</div><div><br></div><div>function([X | _] = List) when is_list(X) -> got a nonempty list of strings!</div><div>function([X | _]) when is_list(X) -> got a nonempty list of integers (one string)</div><div>function([]) -> i am sorry, empty list is here</div><div><br></div><div>there is no way to know having an empty list what it supposed to contain. So an empty list is an empty list</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-07 14:13 GMT+02:00 Andrew McIntyre <span dir="ltr"><<a href="mailto:andrew@medical-objects.com.au" target="_blank">andrew@medical-objects.com.au</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello All,<br>
<br>
A Newbie question,<br>
<br>
Can I tell the difference Between a List of Strings and a Single<br>
String?<br>
<br>
eg the Value in a List may just be "FT" or it might be ["FT", "ST"]<br>
<br>
I do not know in advance if its a single string or a list of strings,<br>
but want to behave differently - actually return the first element of<br>
the list when there are multiple values. I have parsed a variable<br>
hierarchical structure and the hierarchy can vary over instances.<br>
<br>
As strings are lists "is_list" returns true for both. Is that soluble<br>
or do I need to change the data structure to indicate it. Sorry if<br>
this has obvious answer, but new to erlang.<br>
<br>
Thanks<br>
<br>
--<br>
Best regards,<br>
Andrew McIntyre                     mailto:<a href="mailto:andrew@Medical-Objects.com.au">andrew@Medical-Objects.<wbr>com.au</a><br>
<br>
sent from a real computer<br>
<br>
R&D Director<br>
Medical-Objects<br>
4/102 Wises Road<br>
MAROOCHYDORE Q 4558<br>
AUSTRALIA<br>
<br>
<a href="http://www.medical-objects.com.au" rel="noreferrer" target="_blank">www.medical-objects.com.au</a><br>
<br>
<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
</blockquote></div><br></div>