[erlang-questions] strange behaviour of gb_trees

Nico Meyer nico.meyer@REDACTED
Sun May 29 10:02:49 CEST 2011


This is why weakly typed languages require stronlgy disciplined minds 
:-). Not sure if the reverse is also true.

On 28.05.2011 20:17, Ulf Wiger wrote:
>
> On 28 May 2011, at 00:39, Nico Meyer wrote:
>
>> Try instead
>> 1>  T = gb_trees:from_orddict( lists:sort(P) ).
>
> To maintain the abstraction, it should be
>
> 1>  T = gb_trees:from_orddict( orddict:from_list(P) ).
>
> Note that orddicts are not just sorted lists - they are sorted {Key, Value} lists where each key occurs at most once.
>
> Note also:
>
> 2>  orddict:from_list([{a,1},{a,2}]).
> [{a,2}]
> 3>  lists:ukeysort(1,[{a,1},{a,2}]).
> [{a,1}]
>
> Again, stick to the abstraction wherever possible, in order to avoid surprises.
>
> BR,
> Ulf W
>
> Ulf Wiger, CTO, Erlang Solutions, Ltd.
> http://erlang-solutions.com
>
>
>



More information about the erlang-questions mailing list