How can I detect a list [1,2,3] (not a string "example string")?

时间:2016-10-20 19:46:54

标签: erlang

This isnt what I want differentiate a string from a list in Erlang

I want to detect if a variable is a list ([1,2,3]) but when I try with is_list it is true for strings also

List = [2,4,6,8],
String = "example text",

%% Returns true
If is_list(List)->
   io:fwrite("is a list");
true ->
   io:fwrite("is NOT a list")
end.

%% Also returns true
If is_list(String)->
   io:fwrite("is a list");
true ->
   io:fwrite("is NOT a list")
end.

0 个答案:

没有答案