is_proplist in erlang?

前端 未结 2 1937
灰色年华
灰色年华 2021-01-13 01:38

How can get the type of a list. I want to execute the code if the list is proplist. Let us say L = [a,1,b,2,c,3, ...]. Is the list L, I\'m converting it to pro

2条回答
  •  春和景丽
    2021-01-13 02:05

    You can use something like:

    is_proplist([]) -> true;
    is_proplist([{K,_}|L]) when is_atom(K) -> is_proplist(L);
    is_proplist(_) -> false.
    

    but necessary to consider that this function cannot be used in guards.

提交回复
热议问题