我的第一个lua程序之声明变量和逻辑运算符
来源:互联网 发布:通达信均线公式源码 编辑:程序博客网 时间:2024/05/17 08:08
--注释:我的第一个lua程序print("test")io.write("Hello world, from ",_VERSION,"!\n")local a=12 --声明局部变量local d , f = 5 ,10 --declaration of d and f as local variables. d , f = 5, 10; --声明全局变量d, f = 10 --[[declaration of d and f as global variables. Here value of f is nil --]]print ("d=",d);function add(a,b) local c=a+b; return c;end--http://www.yiibai.com/lua/lua_data_types.htmlfunction printType() print(type("What is my type")) --> string t=10 print(type(5.8*t)) --> number print(type(true)) --> boolean print(type(print)) --> function print(type(type)) --> function print(type(nil)) --> nil print(type(type(ABC))) --> stringend--逻辑运算符测试--http://www.yiibai.com/lua/lua_logical_operators.htmlfunction lua_logical_operators()a = 5b = 20if ( a and b )then print("Line 1 - Condition is true" )endif ( a or b )then print("Line 2 - Condition is true" )end--lets change the value ofa and ba = 0b = 10if ( a and b )then print("Line 3 - Condition is true" )else print("Line 3 - Condition is not true" )endif ( not( a and b) )then print("Line 4 - Condition is true" )else print("Line 3 - Condition is not true" )endend-- Variable definition:local a, b-- Initializationa = 10b = 30print("value of a:", a)print("value of b:", b)-- Swapping of variablesb, a = a, bprint("value of a:", a)print("value of b:", b)f = 70.0/3.0print("value of f", f)print("add result c=", add(a,b))printType();a = "Hello "b = "World"print("链接字符串 a with b is ", a..b )print("Length of b is=",#b ) --去字符串长度print("Length of b is=",#"Test" )lua_logical_operators();
0 0
- 我的第一个lua程序之声明变量和逻辑运算符
- Android之我的第一个程序
- Lua和C交互的第一个程序
- 我的第一个lua脚本
- 第一个Lua程序
- LUA第一个程序
- 第一个LUA程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- 我的第一个程序
- Poedu_计算机基础_lesson07_20160903_软件和硬件
- 51单片机 精确控制舵机pwm
- CCF 201503-1 图像旋转
- PostGIS安装
- linux使用flock文件锁解决crontab冲突问题
- 我的第一个lua程序之声明变量和逻辑运算符
- 【NOIP2012模拟10.25】剪草
- Java学习提要——sleep()和wait()的实例与区别
- CCF 201503-2 数字排序
- 对于linux的软连接的设置
- Python基础-几个基础函数应用
- lua中的函数
- CCF 201503-3 节日
- ionic-基于angular-resource的restful开发