初始化linked list并打印:

list = {next = nil, value = 1}

for i=1,5 do

local l = {}

l.next = list

l.value = i+1

list = l

end

while list do

print(list.value)

list=list.next

end


结果

---------- lua ----------

6

5

4

3

2

1


Output completed (0 sec consumed) - Normal Termination