Logo

Programming-Idioms

History of Idiom 17 > diff from v39 to v40

Edit summary for version 40 by andrepd:
[Caml] was not spec

Version 39

2019-09-26, 17:05:52

Version 40

2019-09-26, 17:07:24

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Code
type 'a Tree = 
	| Leaf of 'a
	| Node of 'a tree * 'a tree
Code
type 'a Tree = {
	value: 'a;
	children: 'a tree list;
}