local function createNode( value1, value2, next_node )
return { vol = value1, cur = value2, next = next_node }
end
local function creatList()
return{head = nil, size = 0 }
end
local function add_node( list, value1, value2 )
local new_node = creatList( value1, value2,nil )
if list.head == nil then
list.head = new_node
else
local current = list.head
while current.next do
current = current.next
end
current.next = new_node;
end
list.size = list.size + 1
end
local function print_list()
local current = list.head
while current do
print( 'vol=' .. current.vol)
print( 'cur=' .. current.cur)
current = current.next
end
end
return{
creatList = creatList
add_node = add_node
print_list = print_list
}
local mylist = creatList()
List.add_node( mylist, 220, 10 )
List.add_node( mylist, 221, 11 )
List.print()