balanced binary tree

Willem Broekema willem@REDACTED
Sun Sep 23 17:32:22 CEST 2001


Is there a known error in the code for balanced binary trees in 
'Concurrent programming in Erlang', pp. 62-66?

I have carefully copied the code to balbintree.erl, but there's an error 
in it. Maybe someone else has copied code and can check if these 
statements work for him?

41> B = balbintree:empty_tree().
{nil,nil,0,nil,nil}
42> B2 = balbintree:insert(key1,val1,B).
{key1,val1,1,{nil,nil,0,nil,nil},{nil,nil,0,nil,nil}}
43> B3 = balbintree:insert(key2,val2,B2).
{key1,val1,
       2,
       {nil,nil,0,nil,nil},
       {key2,val2,1,{nil,nil,0,nil,nil},{nil,nil,0,nil,nil}}}
44> B4 = balbintree:delete(key2,B3).

=ERROR REPORT==== 23-Sep-2001::17:01:06 ===
Error in process <0.86.0> with exit value: 
{function_clause,[{balbintree,combine
,[nil,nil,nil,nil,key1,val1,{nil,nil,0,nil,nil}]},{erl_eval,expr,3},{...
** exited: {function_clause,[{balbintree,
                                  combine,
                                  [nil,
                                   nil,
                                   nil,
                                   nil,
                                   key1,
                                   val1,
                                   {nil,nil,0,nil,nil}]},
                              {erl_eval,expr,3},
                              {erl_eval,exprs,4},
                              {shell,eval_loop,2}]} **

- Willem




More information about the erlang-questions mailing list