Commit e9094560 authored by Noric Couderc's avatar Noric Couderc
Browse files

Fixed function so it always returns nonnull

Otherwise it's too difficult to analyse.
parent a78d64d4
......@@ -23,12 +23,12 @@ fun _rec_tree_add(node : nonnull any, x : nonnull int) : nonnull any = {
if (node == leaf()) {
return new Branch(leaf(), x, leaf());
}
var b : Branch := node;
var b : nonnull Branch := node;
if (b.value > x) { return new Branch(_rec_tree_add(b.left, x),
b.value,
b.right); }
if (b.value < x) { return new Branch(b.left, b.value, _rec_tree_add(b.right, x)); }
if (b.value == x) { return b; }
return b;
}
fun tree_contains(t : Tree, x : nonnull int) = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment