Lua 中得for while
来源:互联网 发布:淘宝网运动服女装套装 编辑:程序博客网 时间:2024/05/17 02:24
for i=1,5 doprint(“i is now “ .. i) if i < 2 then print(“small”) elseif i < 4 then print(“medium”) else print(“big”) end end
i = 1while i <= 5 doprint("i is now " .. i) if i < 2 thenprint("small") elseif i < 4 thenprint("medium") elseprint("big") endi = i + 1end---i = 1repeatprint("i is now " .. i) if i < 2 thenprint("small") elseif i < 4 thenprint("medium") elseprint("big") endi = i + 1until i > 5
在Lua中for语句跟其他语言的for类似,语法上有一点点区别。Lua的for语句有两种:数字型和泛型
数字型:
- for var=exp1,exp2,exp3 do
- <执行体>
- end
- for i=1,f(x) do print(i) end
- for i=10,1,-1 do print(i) end
0 0
- Lua 中得for while
- lua中的三种循坏(while,for,repeat)
- shell 中for、while循环
- java中while,for,for简化循环
- C#中foreach,for,while,Do-While循环
- java中循环命令while,for,do while的区别
- Java中循环有三种形式 while、do-while 和 for
- c语言中不用while,for,do-while实现循环
- JAVA中for、while 以及do...while的比较
- Delphi中for、while 使用注意事项
- c++中while和for的优缺点
- shell中for和while区别
- c++中while和for的优缺点
- shell中while+for的使用方法
- java 中 for 与 while 比较。
- Python中while和for的区别
- shell中for、while、until循环
- Python中for循环和while循环
- 把UE、notepad++等添加到右键菜单
- Undefined reference to 'dlsym'
- 深入Java内存模型
- 【矩阵】Spiral Matrix
- 数据结构-A*算法2
- Lua 中得for while
- SQL Server之字符串函数
- java中static作用详解
- ThinkPHP学习笔记
- 如何判断文法是LL(1)SLR(1)LR(1)LALR(1)的?
- hdu2923 Einbahnstrasse
- 删除字符串中模式串
- Cocoa之NSDictionary总结
- UIScrollView 和 UIPageControl实现页面循环播放