清风细雨楼 Design By www.eepep.com
a={}
for i=1,10 do
 a[i]={}
 for j=0,10 do
 if(i%2==0) then
  a[i][j]=0
 end
 end
end

print(a[9][10])
print(a[10][10])
print()

--双端队列

List={}

function List.new()
 return {first = 0,last = -1}
end

function List.pushleft(list,value)
 local first= list.first-1
 list[first] = value
 list.first= first
end

function List.pushright(list,value)
 local last = list.last+1
 list[last]= value
 list.last=last
end

function List.popleft(list)
 local first=list.first
 if(first>list.last) then
 error("list is empty")
 end
 local res= list[first]
 list[first]=nil
 list.first=list.first+1
 return res
end

function List.popright(list)
 local last = list.last
 if last<first then
 error("the list is empty")
 end
 local res = list[last]
 list[last]= nil
 list.last= list.last-1
 return res
end

function List.display(list)
 if(list.first>list.last) then
 error("the list is empty",2)
 end
 for i=list.first ,list.last do
 print(list[i])
 end
end

mylist=List.new()
List.pushleft(mylist,12)
List.pushleft(mylist,"00")
List.pushright(mylist,34)
List.pushright(mylist,56)
List.display(mylist)
print()

function newStack ()
 return {""}
end


function serialize(o)
 if type(o) == "number" then
 io.write(o)
 elseif type(o) == "string" then
  --不要手动加入引号,否则会有边际效应
 io.write(string.format("%q",o))
 elseif type(o) == "table" then
 io.write("{\n")
 for i,v in pairs(o) do
  io.write("  "..i.." = ")
  serialize(v)
  io.write(",\n")
 end
 io.write("}\n")
 end
end

serialize(123)
print()
serialize("112233")
print()
tab = { a=11,haha="www" ,c=333}
serialize(tab)

function basicSerialize (o)
 if type(o) == "number" then
  return tostring(o)
 else
  return string.format("%q", o)
 end
end

function save (name, value, saved)
 saved = saved or {}  -- 参数未传入的初始化
 io.write(name, " = ")
 if type(value) == "number" or type(value) == "string" then
 io.write(basicSerialize(value), "\n")
 elseif type(value) == "table" then
 if saved[value] then
  io.write(saved[value], "\tcircle\n")
 else
  saved[value] = name
  io.write("{}\n")
  for k,v in pairs(value) do
   local fieldname = string.format("%s[%s]", name,
    basicSerialize(k))
   save(fieldname, v, saved)
  end
 end
 else
 error("cannot save a " .. type(value))
 end
end

a = {x=1, y=2; {3,4,5}}
a[2] = a  -- 循环表
a.z = a[1]  -- 共享子表

save('a',a)

运行结果:

nil
0

00
12
34
56

123
"112233"
{
  a = 11,
  c = 333,
  haha = "www",
}
a = {}
a[1] = {}
a[1][1] = 3
a[1][2] = 4
a[1][3] = 5
a[2] = a circle
a["y"] = 2
a["x"] = 1
a["z"] = a[1] circle

清风细雨楼 Design By www.eepep.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
清风细雨楼 Design By www.eepep.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。