mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-11 03:45:29 +03:00
18 lines
338 B
Plaintext
18 lines
338 B
Plaintext
# Generates a tree with numbers in the nodes using 'bend'
|
|
type MyTree:
|
|
Node { val, ~left, ~right }
|
|
Leaf
|
|
|
|
def tree_gen(n, x):
|
|
bend n, x:
|
|
when n != 0:
|
|
return MyTree/Node(x, fork(n - 1, x*2+1), fork(n - 1, x*2+2))
|
|
else:
|
|
return MyTree/Leaf
|
|
|
|
def main:
|
|
depth = 4
|
|
first_val = 1
|
|
return tree_gen(depth, first_val)
|
|
|