leetcode_evaluate reverse polish notation
Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression.(计算逆波兰表达式)
Note:
Division between two integers should truncate toward zero.
The given RPN expression is always valid. That means the expression would always evaluate to a result and there won’t be any divide by zero operation.
Example:
1. 栈使用堆栈来计算逆波兰表达式。其中需要注意的是,题目中要求除法运算没有整除时要向 0 靠近,因此在两个异号的数相除时,应该 ...
给 openresty 的 luajit 安装 luarocks
12345# .bashrcexport OPENRESTY=/usr/local/Cellar/openresty/1.13.6.1export LUAJIT_LIB=$OPENRESTY/luajit/libexport LUAJIT_INC=$OPENRESTY/luajit/include/luajit-2.1
下载 luarocks 解压:
12345678./configure --prefix=/usr/local/luarocks-2.4.3 --with-lua=/usr/local/Cellar/openresty/1.13.6.1/luajit --lua-suffix="jit" --with-lua-include=/usr/local/Cellar/openresty/1.13.6.1/luajit/include/luajit-2.1makesudo make installsudo ln -s /usr/local/Cellar/openresty/1.13.6.1/luajit/bin/luajit /usr/local/bi ...
pil.29lua中调用c函数
我们在说Lua调用C函数的时候,不是说Lua可以调用所有的C函数,我们必须在传递参数和获得结果之间遵从一些协议。同时,必须要注册C函数,也就是说,要以合适的方式给Lua这个函数的地址。
我们先来看一个简单的函数:
static int (lua_State *L) { double d = lua_tonumber(L, 1); lua_pushnumber(L, sin(d)); return 1;}
从C的位置来看,这个函数从Lua state获取一个参数,然后把结果压入Lua state。因此,函数在压入结果前不需要清理栈。在函数返回后,Lua会自动的保存结果然后清理C函数的栈。
在我们可以在Lua中用这个函数前,我们必须先注册。我们使用lua_pushcfunction来实现:获取这个C函数的地址,在Lua中建立一个function的值来保存这个地址。一旦注册后,C函数就跟其他Lua内的函数一样了。
一个快速但是很不简洁的方法是在官方的lua解释器代码lua.c中放入 l_sin的代码,然后在调用了luaL_openlibs函数后加入下面的两行:
lua_pushcfuncti ...
lua中table的单继承与多继承
Table单继承(元表)account = {}
function account:new( o )
o = o or {}
setmetatable(o,self)
self.__index = self
return o
-- body
end
function account:show( v )
print(self.bb…v)
– body
end
a = account:new({bb = 'aa'})
a:show('bb') – aabb
Table多继承(不常用)local function search(k,plist )
– body
for i=1,#plist do
local v = plist[i][k]
if v then
return v
end
end
end
function createClass( … )
– body
local c = {}
local parent = {…}
setmetatable ...
lua串行化_序列化serialization(串行流_字节流)
杂乱字符串转义显示处理-- 匹配符方式 string.format
-- [=[...]=]方式
a = 'a "program lua [[ ]]]]"'
print(string.format('%q',a))
serialize(a) -- [=[a "program lua [[ ]]]]"]=]
number、stirng、table序列化function serialize( o )
if type(o) == "number" then
io.write(o)
elseif type(o) == "string" then
io.write("[=[",o,"]=]")
else
print('b')
end
end
– 杂乱字符串转义显示处理
– 匹配符方式 string.format
– [=[…]=]方式
a = 'a "program lua ...
luajavabridge
•
-- call Java method
local javaClassName = "org/cocos2dx/lua/AppActivity"
local javaMethodName = "showAlertDialog"
local javaParams = {
"How are you ?",
"I''m great !",
function(event)
local str = "Java method callback value is [" .. event .. "]"
btn:s ...
design and implementation of credit evaluation system for healthy aged service
We introduce Collie,an online platform to assess the quality of nursing home service powered by machine learning, which enables user to choose a serial of selected algorithms for different demand. Previous research has proposed the point on how to measure the quality of nursing home service. But traditional service relies on manual investigation which present serval problems like the process of rating quality is complex and insufficient. For the above problems, Collie focus on supporting users ...
开源 waf demo 系列 [ lua waf ]
1nginx-1.12.1 + php5.5.38 + mysql-5.5.32 + centOS6.8_x64 + LuaWaf
lua中的io库
– write输出是print简化版输出,不会自动换行,不可以..等复杂操作io.write(‘okn’)io.write(string.format(“sin(3) = %.4fn”,math.sin(3)))
– read从当前输入中读取 all line *number
–快速逐行读(按块读)local file = assert(io.open(“aa.lua”,’r’))local bufferSize = 2^13 –每行8kb读(最大8kb缓存值)file:read(bufferSize,”*line”)file:close()
– 读取文件生成io流进行操作function write_st( msg ) – body local file = assert(io.open(“aa.lua”,’a’)) local tmp = io.input() file:input(“newinput.lua”) file:write(msg) io.input():close() io.input(tmp)end
the programming language lua and openresty
The Programming Language Lua and OpenResty


