2014年2月27日

Lua 简单的IO交互 和迷宫代码

摘要: 1 function room1 () 2 print("in room1") 3 local move = io.read() 4 if move == "south" then 5 return room3() 6 elseif move == "east" then 7 return room2() 8 else 9 print("invalid move")10 return room1() -- stay in the same room11 end12 end13 14 ... 阅读全文

posted @ 2014-02-27 08:13 Step-BY-Step 阅读(387) 评论(0) 推荐(0) 编辑

Lua基础 函数(一)

摘要: 转自:http://blog.csdn.net/wzzfeitian/article/details/8653101在Lua中,函数是对语句和表达式进行抽象的主要方法。既可以用来处理一些特殊的工作,也可以用来计算一些值。下面有3个例子,分别将函数当作一条语句;当作表达式(后面两个是一类)。[plain]view plaincopyprint(8*9,9/8)-->721.125a=math.sin(3)+math.cos(10)-->a=-0.69795152101659print(os.date())-->SatMar912:14:082013函数如果带参数,那么就要用(a 阅读全文

posted @ 2014-02-27 02:47 Step-BY-Step 阅读(322) 评论(0) 推荐(0) 编辑

Stateless Iterators

摘要: As the name implies, a stateless iterator is an iterator that does not keep any state by itself. Therefore, we may use the same stateless iterator in multiple loops, avoiding the cost of creating new closures.On each iteration, theforloop calls its iterator function with two arguments: the invariant 阅读全文

posted @ 2014-02-27 02:19 Step-BY-Step 阅读(199) 评论(0) 推荐(0) 编辑

Lua print on the same line

摘要: In Pascal, I havewriteandwriteln. Apparently Lua'sprintis similar towritelnof Pascal. Do we have something similar towriteof Pascal? How can consecutive print commands send their output to the same line?print("Hello")print("World")Output:HelloworldI want to have this:Hello wo 阅读全文

posted @ 2014-02-27 01:58 Step-BY-Step 阅读(264) 评论(0) 推荐(0) 编辑

What is the Best Programming Language to Learn in 2014?

摘要: It’s been a year since I revealedthe best languages to learn in 2013. Once again, I’ve examined the data produced byJobs Tractorwho analyzed more than 45,000 developer jobs advertised on Twitter during the past twelve months. The results:Java8,731PHP8,238Objective-C5,859Java for Android4,312SQL3,553 阅读全文

posted @ 2014-02-27 01:51 Step-BY-Step 阅读(447) 评论(0) 推荐(0) 编辑

导航