[erlang-questions] Q: Differenciating between List and List of Lists

jm <>
Thu Oct 16 01:29:49 CEST 2008


Thanks folks.

Jeff.

fess wrote:
> On Oct 15, 2008, at 1:57 AM, Roberto Aloi wrote:
>
>   
>> 1> List = "aList".
>> "aList"
>> 2> ListOfLists = ["first", "second"].
>> ["first","second"]
>> 3> is_list(lists:nth(1,List)).
>> false
>> 4> is_list(lists:nth(1,ListOfLists)).
>> true
>> 5> is_integer(lists:nth(1,ListOfLists)).
>> false
>> 6> is_integer(lists:nth(1,List)).
>> true
>>
>> Just remember to check for empty lists!!!
>>     
>
> I like hd() for brevity in place of lists:nth(1,...)
>
> 1> List = "aList".
> "aList"
> 2> ListOfLists = ["first", "second"].
> ["first","second"]
> 3> is_list(hd(List)).
> false
> 4> is_list(hd(ListOfLists)).
> true
> 5> is_integer(hd(ListOfLists)).
> false
> 6> is_integer(hd(List)).
> true
>
> --fess
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   



More information about the erlang-questions mailing list