proplists:unfold/1
把列表里的原子都打开呈现出来
用法:
unfold(List) -> List
内部实现:
-spec unfold(ListIn) -> ListOut when
ListIn :: [term()],
ListOut :: [term()].
unfold([P | Ps]) ->
if is_atom(P) ->
[{P, true} | unfold(Ps)];
true ->
[P | unfold(Ps)]
end;
unfold([]) ->
[].
把列表 List 里的原子都以 {Atom, true} 的形式呈现打开出来。
proplists:unfold([a, "b", 1, {c, false}, {d, true}, [e]]).