A lightweight programming environment for desktop and mobile devices
-- like map, but support nils inside arr
-- arr must provide its length in an 'n' field,
-- as returned by 'unpack'.
map_nil = function(arr, f)
	local result = {}
	for i=1,arr.n do
		result[i] = f(arr[i])
	end
	result.n = arr.n
	return result
end