块列表LUA 5.1.5
我正在使用 Lua 5.1.5 并尝试将表切成块(?)。我正在尝试将表格分解成这样的内容:
{{a, b, c ,d}, {e, f, g, h}, ...}
有人知道如何做到这一点吗?
编辑:忘记了 Lua 有表格而不是列表,所以替换了那些
I am using Lua 5.1.5 and trying to cut tables into chunks(?). I am trying to break apart a table into something like this:
{{a, b, c ,d}, {e, f, g, h}, ...}
Anyone got an idea on how to do that?
Edit: Forgot Lua had tables instead of lists so replaced those
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
改编这段代码:
关键点是函数unpack,它是 Lua 5.1 中的全局函数,但在 Lua 5.2+ 中驻留在
table
中。Adapt this code:
The key point is the function unpack, which is a global function in Lua 5.1 but resides in
table
in Lua 5.2+.此代码不尾随
nil
,基于 @lhf anser输出
This code doesn't trailing
nil
, based on @lhf anserOutput