Skip to content

Instantly share code, notes, and snippets.

@gradha
Forked from acolley/gist:7371049
Created November 8, 2013 22:22
Show Gist options
  • Select an option

  • Save gradha/7378640 to your computer and use it in GitHub Desktop.

Select an option

Save gradha/7378640 to your computer and use it in GitHub Desktop.
type
TNode = object
id: int
child_l: PNode
child_r: PNode
PNode = ref TNode
var
counter = 0
wurzel: PNode = nil
proc create_node(l: PNode, r: PNode): PNode =
new(result)
result.id = counter
result.child_l = l
result.child_r = r
inc(counter)
proc make_tree(depth: int): PNode =
if depth > 1:
result = create_node(make_tree(depth - 1), make_tree(depth - 1))
else:
result = create_node(nil, nil)
when isMainModule:
var num = 24
# benchmarking code can go here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment