1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

example: improve binary search tree example (#10226)

This commit is contained in:
Ruofan XU
2021-05-28 01:13:02 +08:00
committed by GitHub
parent 2b62dca000
commit 4e55b9c08e
3 changed files with 32 additions and 24 deletions

View File

@ -2367,7 +2367,7 @@ type Tree = Empty | Node
// sum up all node values
fn sum(tree Tree) f64 {
return match tree {
Empty { f64(0) } // TODO: as match gets smarter just remove f64()
Empty { 0 }
Node { tree.value + sum(tree.left) + sum(tree.right) }
}
}