[ create a new paste ] login | about

Link: http://codepad.org/ciNsLvtB    [ raw code | output | fork ]

Lua, pasted on Mar 3:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function contains(list, x)
	for _, v in pairs(list) do
		if v == x then return true end
	end
	return false
end

list = {11, 22, 33}

x = 22
print(contains(list, x))

x = 44
print(contains(list, x))


Output:
1
2
true
false


Create a new paste based on this one


Comments: