Lua - 生成数字序列 [英] Lua - generate sequence of numbers

查看:371
本文介绍了Lua - 生成数字序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何基于的第一个和最后一个数字为生成一个整数序列来循环?

How do I generate a sequence of integer numbers based on first and last number for for to loop over?

以下伪代码

for i in sequence(4,9) do
  print(i)
end

应产生以下输出

4
5
6
7
8
9

请简要说明解决方案在后台做了什么,以及哪些术语可以让人找到解决方案。

Please include a short explanation what the solution does in the background and what terminology would have allowed one to find the solution.

搜索尝试导致无法搜索大量文档。

Search attempts lead to unsearchable huge pages of documentation.

推荐答案

您可以使用数字换循环来做到这一点。您可以在我参考的Lua部分中找到详细信息,或者在上找到Lua手册部分。声明

You can use numeric for loop to do that. You will find details in Programming in Lua section I referenced or the Lua manual section on For statement.

这篇关于Lua - 生成数字序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆