Logo

Programming-Idioms

History of Idiom 17 > diff from v34 to v35

Edit summary for version 35 by Kng:
New Lua implementation by user [Kng]

Version 34

2017-10-04, 20:22:26

Version 35

2018-04-03, 08:28:06

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
local function Tree(v, c)
	return {
		val = v,
		children = c
	}
end