[erlang-questions] distinguish proplists vs. lists of proplists

Adam Krupicka akrupicka@REDACTED
Tue Sep 15 19:58:01 CEST 2015


Not exactly sure what you're asking, but you can use pattern matching to
distinguish a list prom a proplist -  assuming your ordinary lists do
not contain two-element tuples:

handle(List) when is_list(List) ->
    ...;
handle([{_, _} | _] = Proplist) ->
    ....


A.

Excerpts from Mr rty ff's message of 2015-09-15 16:58:33 +0000:
> 
> Hi
> 
> I write a function which gets proplists or list of proplists anf key. if the input is proplists I just use proplists:get_value to find a value corresponding to key. But if the input is lists of proplists I need to iterate over all its elements. and look for key in each of them. I amnot sure how to distinguish lists vs. proplists. lists:is_list returns true for both of them.
> 
> Thanks



More information about the erlang-questions mailing list