BeginProgram: Lists6

BeginFunction: [<string>] reverseList([<string>] x)
	ListDecl: [<string>] y
	BeginFor: <int> i in IRANGE(listsize(x) - 1, 0, -1)
		Statement: push(y, x[i])
	EndFor
	Return: y
EndFunction

BeginMain:
	ListDecl: [<string>] names := "Fred", "Wilma", "Barney", "Betty"

	# Print out the names from the list
	BeginForEach: auto name in names
		PrintLine: "Hello, ", name, "!"
	EndForEach
	
	Assign: names = reverseList(names)
	# Print out the names from the reversed list
	BeginForEach: auto name in names
		PrintLine: "Hello, ", name, "!"
	EndForEach
	
	PrintLine: listToString(names)
EndMain
EndProgram
