I have a question about lua , that question is
what different about these code ??
this
And this
They aren't same ??
Can someone explain me??
Sorry for bad English
Scripts
What is different (2 Lua Scripts)?
What is different (2 Lua Scripts)?
1

A(a, b)
	local c = {}
	for d = 1, a do
		c[d] = b
	end
	return d
end
A(a)
	local c = {}
	for d = 1, a do
		c[d] = 0
	end
	return d
end
MAX-russia: He wants an explanation, not an answer to confirm what he already knows. Read, Max.
Yates has written
MAX-russia: He wants an explanation, not an answer to confirm what he already knows. Read, Max.
Yates has writtenfunction initArray(m)
	return Array(m,0)
end
function Array(size,value)
	local array = {}
	for i = 1, size do
		array[i]=value
	end
	return array
end
Apache uwu has writtenfunction initArray(m)
	return Array(m,0)
end
function Array(size,value)
	local array = {}
	for i = 1, size do
		array[i]=value
	end
	return array
end
function initArr(size,value)
	value=value or 0
	local array = {}
	for i = 1, size do
		array[i]=value
	end
	return array
end
Alistaire already said, mind you):
The first function, initArray(m), allows you to create a table, an "array", of size m with all of its entries (from 1 to m) set to zero.
The second function, Array(size,value), lets you create an "array" with the size size with all of its entries (from 1 to size) set to value.-- I need an array of points, I guess I can just use a table of length two to represent points and have them pre-initialized to be all {0,0}
arr = Array(10, {0,0})
-- Somewhere during the calculation, I needed to add 1 to each of the x components
for i=1,10 do
	arr[i][1] = arr[i][1]+1
	-- I should expect each point to contain (1,0) right?
end
-- For sanity check, is my first point still 1,0?
print(unpack(arr[1]))
function doublearray(m,n,k) --m is amount of first-level fields, n is of second-level ones
local a, x, y = {}
for x = 0, m do a[x] = {}
for y = 0, n do
a[x][y] = k
end
end
return a
end
1
