【发布时间】:2021-01-13 05:40:57
【问题描述】:
我需要帮助来使用 for 循环为我的作业创建这个适应性强的反向数组
function for_loop2(a,b)
local out = {}
-- a is the starting number in the array
-- b is the length of the array
--Put your code between here ****************
--and here **********************************
return out
end
is( for_loop2(4,4), {4,3,2,1}, 'For loop adaptable reversed array creation')
is( for_loop2(9,9), {9,8,7,6,5,4,3,2,1}, 'For loop adaptable reversed array creation')
is( for_loop2(4,9), {4,3,2,1,0,-1,-2,-3,-4}, 'For loop adaptable reversed array creation')
report()
除了https://www.lua.org/pil/contents.html 之外,我可以参考的任何材料都将不胜感激 因为我需要更多示例来理解这些概念。
【问题讨论】: