The line
(coalton (tree:insert-or-replace tree:empty 0))
results in
#.(TREE::BRANCH TREE::COLOR/BLACK #.TREE:EMPTY 0 #.TREE:EMPTY)
whereas the line
(coalton (unwrap (tree:insert tree:empty 0)))
results in
#.(TREE::BRANCH TREE::COLOR/RED #.TREE:EMPTY 0 #.TREE:EMPTY)
This causes issues when removing elements after having inserted several elements via tree:insert:
(coalton (tree:remove (unwrap (tree:insert (unwrap (tree:insert tree:empty 0)) 1)) 0))
results in the error:
Attempt to `remove-max` on an empty tree.
This issue also affects map:insert.
This issue can be addressed by applying the as-black function before returning the evaluation of the insert function, such as (map as-black (ins tre)) however, there may be more to this issue, and it may be an issue for other functions as well, including replace.
The line
(coalton (tree:insert-or-replace tree:empty 0))
results in#.(TREE::BRANCH TREE::COLOR/BLACK #.TREE:EMPTY 0 #.TREE:EMPTY)
whereas the line(coalton (unwrap (tree:insert tree:empty 0)))
results in#.(TREE::BRANCH TREE::COLOR/RED #.TREE:EMPTY 0 #.TREE:EMPTY)
This causes issues when removing elements after having inserted several elements via
tree:insert
:(coalton (tree:remove (unwrap (tree:insert (unwrap (tree:insert tree:empty 0)) 1)) 0))
results in the error:Attempt to `remove-max` on an empty tree.
This issue also affects
map:insert
.This issue can be addressed by applying the
as-black
function before returning the evaluation of theinsert
function, such as(map as-black (ins tre))
however, there may be more to this issue, and it may be an issue for other functions as well, includingreplace
.