is_proplist在erlang? [英] is_proplist in erlang?
本文介绍了is_proplist在erlang?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取列表的类型。如果列表是proplist,我想执行代码。
让我们说 L = [a,1,b,2,c,3,...]
。是列表L,我把它转换为proplist像
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 proplist like
L = [{a,1}, {b,2}, {c,3}, ...].
如何确定列表是否是proplist? erlang:is_list / 1
对我没有用。
How can I determine whether the list is a proplist? erlang:is_list/1
is not useful for me.
推荐答案
你可以使用以下内容:
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.
这篇关于is_proplist在erlang?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文