summaryrefslogtreecommitdiff
path: root/tigrou/linked-list/linked-list.tih
blob: b890f3a9fa3fefacc4012293f723d1f8cffdeeb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
type node = {value : int, next : node}
function append(list: node, element: int) =
	if list.next = nil then
		list.next := node{value = element, next = nil}
	else
		append(list.next, element)

function display(list: node) =
	if list <> nil then
	(
		print_int(list.value);
		(if list.next <> nil then
			print(" -> "));
		display(list.next)
	)