跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
关于计算器百科
资助计算器百科
联系计算器百科
聊天室
友情链接
计算器百科
搜索
搜索
外观
登录
个人工具
登录
查看“︁TI-Lua/流程控制”︁的源代码
页面
讨论
不转换
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
臺灣正體
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
TI-Lua/流程控制
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 流程控制 == 本节将讨论 TI-Lua 中的流程控制,其中包括条件判断、循环与<del>无条件跳转</del>。 === 条件判断 === <code>if-else</code> 结构是基本的条件判断流程。其结构如下: <syntaxhighlight lang="lua"> if cond then -- executes when cond is true else -- executes when cond is false end </syntaxhighlight> 其中,<code>cond</code> 是一个[[TI-Lua/基本数据结构|布尔值]]。下同。 === 循环 === 循环体分为 <code>for</code> 循环、 <code>while</code> 循环和 <code>repeat-until</code> 循环。我们首先来讨论 <code>while</code> 循环。 ==== <code>while</code> 循环 ==== <code>while</code> 循环结构如下: <syntaxhighlight lang="lua"> while cond do -- something end </syntaxhighlight> ==== <code>repeat-until</code> 循环 ==== <code>repeat-until</code> 循环结构如下: <syntaxhighlight lang="lua"> repeat -- something until cond </syntaxhighlight> ==== <code>for</code> 循环 ==== <code>for</code> 循环具有两种形式。第一种是”步进型“,第二种是”遍历型“(即 <code>foreach</code>)。 <code>for</code> 循环结构如下: <syntaxhighlight lang="lua"> -- Form 1 for v = v_begin, v_end, v_step do -- something end -- Form 2 for v1, v2, ..., vn in a_list do -- something end </syntaxhighlight> === <del>跳转</del> === {{Info | color = yellow | text = 由于 TI-Lua 是 Lua 5.1 的实现,而 <code>goto</code> 指令于 Lua 5.2 才添加,因此该小节可能不具有实际意义。 }}
该页面嵌入的页面:
Template:Info
(
查看源代码
)
Template:Lan
(
查看源代码
)
Template:Navbar
(
查看源代码
)
Template:Navbox
(
查看源代码
)
Template:TI-Lua
(
查看源代码
)
Template:·
(
查看源代码
)
返回
TI-Lua/流程控制
。
搜索
搜索
查看“︁TI-Lua/流程控制”︁的源代码
添加话题