lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I was writing a code to do linear search:
What wrong?

function linearSearch(table, element)
local position=0
while position<#table do
if table[position]==element then
return position
else
position=position+1
end
end
end
math.randomseed(is.time())
array={}
for i=1,10 do
array[i]=math.random(0,99)
end
print(table.concat(vetor,","))
io.write("Enter a number to search in  array:\n")
num=io.read("*n")
buscaLinear(array,num)

Help me, guys!
Thanks a lot!

Jorge Eduardo