adjust directory 2

This commit is contained in:
JamesonHuang
2015-06-28 14:39:56 +08:00
parent b09950bf62
commit 4039994946
1767 changed files with 503365 additions and 0 deletions

View File

@ -0,0 +1,14 @@
local val = "1,2,3,4,5,6,0"
--local val = "1,2,3,4,5,6,0"
--local val = "1,2,3,4,5,6,0"
--local val = "1,3,5"
local repeat_var = "0000000"
for i = 1, #val, 2 do
idx = string.sub(val, i, i)
if idx ~= tostring(0) then
repeat_var = string.sub(repeat_var, 0, idx - 1) .. tostring(1) .. string.sub(repeat_var, idx + 1, #repeat_var)
else
repeat_var = string.sub(repeat_var, 1, #repeat_var - 1) .. tostring(1)
end
print(repeat_var)
end

View File

@ -0,0 +1,2 @@
local str = "hello world!"
print(string.sub(str, -3, -1))

View File

@ -0,0 +1,22 @@
--[[print("lua")
tmp2 = os.date("!*t")
print(tmp2)
tmp = os.date("*t")
print(os.date())
print(tmp)
local x = os.time()
print(x)
]]--
print(os.date(now))
print(os.date("%x"))
print(os.date("%M"))
print(os.date("*t", now)) --table
print(os.date("!*t", now)) --UTC
--字符串形式
local tmp = os.date(now)
print(tmp)
--转table
local tmp2 = os.date("!*t", tmp)
print( os.time(tmp2))

View File

@ -0,0 +1,38 @@
---------------------Lua遍历字符串的每个字符-----------------------
local s = "hello hi, again"
print(string.len(s))
--[[----failed,expected table, not a string
for i, v in ipairs(s) do
print(v)
end
]]--
--[[success
for i = 0, #s do
print(string.sub(s, i, i))
end
]]--
--------------------------wifi repeat代码--------------------------
local repeat_var_from_http = "1111111"
if string.len(repeat_var_from_http) ~= 7 then
print("len error")
return
end
local week_repeat = ""
for i = 1, #repeat_var_from_http do
tmp = string.sub(repeat_var_from_http, i, i)
if tmp == "1" then
if(i == #repeat_var_from_http) then
week_repeat = week_repeat..0
break
end
week_repeat = week_repeat..tostring(i)..","
end
end
print(week_repeat)

View File

@ -0,0 +1,2 @@
local var = 10 > 9 and 10 or 9
print(var)