update NOTICE and LICENSE
[nit.git] / tests / shootout_binarytrees.nit
index e86a5ff..6ccd4be 100644 (file)
 # contributed by Jean Privat
 
 class TreeNode
-    attr _left: TreeNode
-    attr _right: TreeNode
-    attr _item: Int
+    var _left: nullable TreeNode
+    var _right: nullable TreeNode
+    var _item: Int
 
 
-    init(left: TreeNode, right: TreeNode, item: Int)
+    init(left: nullable TreeNode, right: nullable TreeNode, item: Int)
        do
            _left = left
            _right = right
@@ -33,7 +33,7 @@ class TreeNode
        end
 
 
-    meth item_check: Int
+    fun item_check: Int
        do
            if _left == null then
                return _item
@@ -43,7 +43,7 @@ class TreeNode
        end
 end
 
-meth bottom_up_tree(item: Int, depth: Int): TreeNode
+fun bottom_up_tree(item: Int, depth: Int): TreeNode
     do
        if depth > 0 then
            var item_item = 2 * item
@@ -65,7 +65,7 @@ if min_depth + 2 > max_depth then
 end
 
 var stretch_depth = max_depth + 1
-var stretch_tree = bottom_up_tree(0, stretch_depth)
+var stretch_tree: nullable TreeNode = bottom_up_tree(0, stretch_depth)
 
 print("stretch tree of depth {stretch_depth}\t check: {stretch_tree.item_check}")