Logo

Programming-Idioms

History of Idiom 9 > diff from v20 to v21

Edit summary for version 21 by elbrujohalcon:
New Erlang implementation by user [elbrujohalcon]

Version 20

2016-03-28, 12:33:53

Version 21

2016-07-12, 21:07:45

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Code
-type binary_tree(T) ::
	#{ data := T
	 , left := binary_tree(T)
	 , right := binary_tree(T)
	 }.
Comments bubble
We just define the type here. Next step would be to implement a module with the required functions to access it and even make it opaque.