`
邢邢色色
  • 浏览: 229024 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

QuickLuaTour翻译流水账(31-38)

Lua 
阅读更多
-- Example 31   --[[

  Standard Libraries

  Lua has standard built-in libraries for common operations in
  math, string, table, input/output & operating system facilities.

  External Libraries

  Numerous other libraries have been created: sockets, XML, profiling,
  logging, unittests, GUI toolkits, web frameworks, and many more.

]]

------- Output --------


-- 例子 31   --[[
  标准库

  Lua 有许多用于通用操作的标准的内建库,比如数学
  字符串,表,输入/输出和操作系统的工具

  外部库

  现有的其它的库有N多:sockets, XML, 性能分析,
  日志,单元测试,图形界面工具,web框架等等

]]


-- Example 32  -- Standard Libraries - math.

-- Math functions:
-- math.abs, math.cos, math.asin, math.atan, math.atan2,
-- math,ceil, math.cos, math.cosh, math.deg, math.exp, math.floor,
-- math.fmod, math.frexp, math,huge, math.ldexp, math.log, math.log10
-- math.max, math.min, math.modf, math.pi, math.pow, math.rad,
-- math.random, math.randomseed, math.sin, math.sinh, math.sqrt,
-- math.tan, math.tanh

print(math,sqrt(9), math.pi)


------ Output ------

3          3.1415926535898


-- Example 33  -- Standard Libraries - string.

-- String functions:
-- string.byte, string.char, string.dump, string.find, string.format,
-- string.gfind, string.gsub, string.len, string.lower, string.match,
-- string.rep, string.reverse, string.sub, string.upper

print(string.upper("lower"), string.rep("a", 5), string.find("abcde", "cd"))

------ Output ------

LOWER aaaaa  3         4


-- Example 34  -- Standard Libraries - table.

--Table functions:
-- table.concat, table.insert, table.maxn, table.remove, table.sort

a={2}
table.insert(a,3);
table.insert(a,4);
table.sort(a,function(v1,v2) return v1 > v2 end)
for i,v in ipairs(a) do print(i,v) end

------ Output ------

1      4
2      3
3      2


-- Example 35  -- Standard Libraries - input/output.

-- IO functions:
-- io.close, io.flush, io.input, io.lines, io.open, io.output, io.popen,
-- io.read, io.stderr, io.stdin, io.stdout, io.tmpfile, io.type, io.write,
-- file:close, file:flush, file:lines, file:read,
-- file:seek, file:setvbuf, file:write

print(io.open("file doesn't exist", "r"))


------ Output ------

nil     file doesn't exist: No such file or derectory   2


-- Example 36  -- Standard Libraries - operating system facilities.

-- OS functions:
-- os.clock, os.date, os.difftime, os.execute, os.exit, os.getenv,
-- os.remove, os.rename, os.setlocale, os.time, os.tmpname

print(os.date())

------ Output ------

06/20/12 11:48:30


-- Example 37  -- External Libraries
-- Lua has support for external modules using the 'require' function
-- INFO:A dialog will popup but it could get hidden behind the console.

require("iuplua")
ml = iup.multiline
    {
        expand="YES",
        value="Quit this multiline edit app to continue Tutorial!",
        border="YES"
    }

dlg = iup.dialog{ml; title="IupMultiline", size="QUARTERxQUARTER",}
dlg:show()
print("Exit GUI app to continue!")
iup.MainLoop()


------ Output --------
Exit GUI app to continue!


-- Example 38   --[[
  to learn more about Lua scripting see
  Lua Tutorials: http://lua-users.org/wiki/TutorialDirectory
  "Programing in Lua" Book: http://www.inf.puc-rio.br/~reberto/pil2/

  Lua 5.1 Reference Manual:
      Start/Programs/Lua/Documentation/Lua 5.1 Reference Manual

  Examples Start/Programs/Lua/Examples
]]


------ Output -------

]]
 
分享到:
评论

相关推荐

    前端菜鸡流水账日记 - Pagination分页 - 封装得分页

    封装好得ant组件库得分页得vue文件,引入到项目中可以直接使用

    前端菜鸡流水账日记 - threejs和cesium

    解码器的第二个文件

    库存货物流水明细账-Excel模板

    【作品名称】:库存货物流水明细账-Excel模板 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。

    旺财流水账2.0绿色版(免费流水账软件)

    旺财流水账是一款流水账软件。在管理您在日常生活中的现金收支,可建立多个帐套、无限自定义分类,多种图形统计及账务报表,并可通过插件不断增强扩展软件功能。 1.多账套 2.权限支持 3.无限扩展分类 4.无限...

    进销存-库存货品流水明细账-Excel模板

    【作品名称】:进销存-库存货品流水明细账-Excel模板 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。

    广告公司SR流水账ERP开发

    广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司SR流水账ERP开发 广告公司...

    账本模板-总账-明细账-报表.xls

    账本模板-总账-明细账-报表.xls

    好用的--银行流水账打印程序 行业管理

    好用的--银行流水账打印程序 行业管理

    工程流水账记录工具

    "工程流水账记录工具"就是这样一个实用的解决方案,它旨在帮助用户方便地记录和整理他们的流水账目,以便于后期的数据分析和查询。下面我们将深入探讨这个工具的核心功能、可能的设计原理以及如何利用它来提升工作...

    旺财流水账 v6.1.zip

    旺财流水账是一款流水账软件。在管理您在日常生活中的现金收支,可建立多个帐套、无限自定义分类,多种图形统计及账务报表,并可通过插件不断增强扩展软件功能。 旺财流水账入手简单,您需要在使用前设置好收支分类...

    Excel模板流水账.zip

    标题中的“Excel模板流水账.zip”表明这是一个包含Excel模板的压缩文件,主要用于记录和管理日常的财务流水。在企业或个人财务管理中,流水账是一种重要的工具,它详细记录了收入和支出的情况,帮助用户了解资金流动...

    现金流水账模版

    非常简单易用的适合中小企业和个人使用的现金流水账EXCEL工具

    小型流水账计算器

    使用该软件对自己的流水账进行计算,让自己每天的经济生活更加清晰。

    工作记录流水账

    标题中的“工作记录流水账”指的是使用数据库管理系统(如Microsoft Access)来跟踪和记录日常工作活动的一种方式。在企业管理中,这种记录系统可以帮助员工记录任务完成情况,提高工作效率,并为管理层提供工作进度...

    模板-现金收支流水账.xls

    日常记账使用,现金流水账表格。用于家庭日常收支记账和小商店等的流水记账。表格分月份和汇总表。简单易用,一目了然

    免费流水账,家庭小公司财务软件

    标题中的“免费流水账,家庭小公司财务软件”表明我们关注的是一个专为家庭或小型企业设计的财务管理系统,主要用于记录日常收支情况。这类软件通常包含基础的会计功能,如收入记录、支出追踪、账户余额计算等,帮助...

    个人流水账管理程序

    标题中的“个人流水账管理程序”是指一种专为个人设计的财务管理工具,它主要用于记录、管理和分析个人的日常收支情况。这种程序可以帮助用户清晰地了解自己的财务状况,从而更好地规划预算,控制支出,并做出明智的...

    EXCEL 账务流水账

    EXCEL 账务流水账 模板 包括明细,统计,图表

    财务收支流水账-图表分析-自动计算.xls

    工资表,财务报表,对账表,付款申请,财务报告,费用支出表 适用人群:学习不同技术领域的小白或进阶学习者;可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。

Global site tag (gtag.js) - Google Analytics