当前位置: 首页 > news >正文

b2b内容营销网站seo优化总结

b2b内容营销,网站seo优化总结,网站开发一般流程,仿门户网站多功能js相册画廊源码一、Lua数组 数组,就是相同数据类型的元素按一定顺序排列的集合,可以是一维数组和多维数组。 在 Lua 中,数组不是一种特定的数据类型,而是一种用来存储一组值的数据结构。 实际上,Lua 中并没有专门的数组类型&#xf…

一、Lua数组

数组,就是相同数据类型的元素按一定顺序排列的集合,可以是一维数组和多维数组。
在 Lua 中,数组不是一种特定的数据类型,而是一种用来存储一组值的数据结构。
实际上,Lua 中并没有专门的数组类型,而是使用一种被称为 “table” 的数据结构来实现数组的功能。
Lua 数组的索引键值可以使用整数表示,数组的大小不是固定的。
在 Lua 索引值是以 1 为起始,但你也可以指定 0 开始。

(一)一维数组

一维数组是最简单的数组,其逻辑结构是线性表。
使用索引访问数组元素:

	-- 创建一个数组local myArray = {10, 20, 30, 40, 50}-- 访问数组元素print(myArray[1])  -- 输出 10print(myArray[3])  -- 输出 30

要计算数组的长度(即数组中元素的个数),你可以使用 # 操作符:

	local myArray = {10, 20, 30, 40, 50}-- 计算数组长度local length = #myArrayprint(length) -- 输出 5

在这里插入图片描述

array = {"Lua", "Tutorial"}for i= 0, 2 doprint(array[i])
end

在这里插入图片描述
正如你所看到的,我们可以使用整数索引来访问数组元素,如果指定的索引没有值则返回 nil。

除此外我们还可以以负数为数组索引值:

array = {}for i= -2, 2 doarray[i] = i *2
endfor i = -2,2 doprint(array[i])
end

在这里插入图片描述

(二)多维数组

多维数组即数组中包含数组或一维数组的索引键对应一个数组。

以下是一个三行三列的阵列多维数组:

-- 初始化数组
array = {}
for i=1,3 doarray[i] = {}for j=1,3 doarray[i][j] = i*jend
end-- 访问数组
for i=1,3 dofor j=1,3 doprint(array[i][j])end
end

在这里插入图片描述
不同索引键的三行三列阵列多维数组:

-- 初始化数组
array = {}
maxRows = 3
maxColumns = 3
for row=1,maxRows dofor col=1,maxColumns doarray[row*maxColumns +col] = row*colend
end-- 访问数组
for row=1,maxRows dofor col=1,maxColumns doprint(array[row*maxColumns +col])end
end
1
2
3
2
4
6
3
6
9

二、Lua迭代器

迭代器(iterator)是一种对象,它能够用来遍历标准模板库容器中的部分或全部元素,每个迭代器对象代表容器中的确定的地址。
在 Lua 中迭代器是一种支持指针类型的结构,它可以遍历集合的每一个元素。

(一)泛型 for 迭代器

泛型 for 在自己内部保存迭代函数,实际上它保存三个值:迭代函数、状态常量、控制变量。
泛型 for 迭代器提供了集合的 key/value 对,语法格式如下:

for k, v in pairs(t) doprint(k, v)
end

上面代码中,k, v为变量列表;pairs(t)为表达式列表。
查看以下实例:

array = {"Google", "Runoob"}for key,value in ipairs(array) 
doprint(key, value)
end
1  Google
2  Runoob
以上实例中我们使用了 Lua 默认提供的迭代函数 ipairs。下面我们看看泛型 for 的执行过程:首先,初始化,计算 in 后面表达式的值,表达式应该返回泛型 for 需要的三个值:迭代函数、状态常量、控制变量;与多值赋值一样,如果表达式返回的结果个数不足三个会自动用 nil 补足,多出部分会被忽略。
第二,将状态常量和控制变量作为参数调用迭代函数(注意:对于 for 结构来说,状态常量没有用处,仅仅在初始化时获取他的值并传递给迭代函数)。
第三,将迭代函数返回的值赋给变量列表。
第四,如果返回的第一个值为nil循环结束,否则执行循环体。
第五,回到第二步再次调用迭代函数
在Lua中我们常常使用函数来描述迭代器,每次调用该函数就返回集合的下一个元素。Lua 的迭代器包含以下两种类型:- 无状态的迭代器
- 多状态的迭代器

(二)无状态的迭代器

无状态的迭代器是指不保留任何状态的迭代器,因此在循环中我们可以利用无状态迭代器避免创建闭包花费额外的代价。
每一次迭代,迭代函数都是用两个变量(状态常量和控制变量)的值作为参数被调用,一个无状态的迭代器只利用这两个值可以获取下一个元素。
这种无状态迭代器的典型的简单的例子是 ipairs,它遍历数组的每一个元素,元素的索引需要是数值。
以下实例我们使用了一个简单的函数来实现迭代器,实现数字 n 的平方:

function iter (a, i)i = i + 1local v = a[i]if v thenreturn i, vend
endfunction ipairs (a)return iter, a, 0
end

(三)多状态的迭代器

很多情况下,迭代器需要保存多个状态信息而不是简单的状态常量和控制变量,最简单的方法是使用闭包,还有一种方法就是将所有的状态信息封装到 table 内,将 table 作为迭代器的状态常量,因为这种情况下可以将所有的信息存放在 table 内,所以迭代函数通常不需要第二个参数。
以下实例我们创建了自己的迭代器:

array = {"Google", "Runoob"}function elementIterator (collection)local index = 0local count = #collection-- 闭包函数return function ()index = index + 1if index <= countthen--  返回迭代器的当前元素return collection[index]endend
endfor element in elementIterator(array)
doprint(element)
end

文章转载自:
http://dinncostraightaway.ssfq.cn
http://dinncosimilitude.ssfq.cn
http://dinncowavilness.ssfq.cn
http://dinncospicknel.ssfq.cn
http://dinncoundistinguishable.ssfq.cn
http://dinncooilskin.ssfq.cn
http://dinncodoorstop.ssfq.cn
http://dinncounbending.ssfq.cn
http://dinnconimblewit.ssfq.cn
http://dinncowinterbourne.ssfq.cn
http://dinncoyaffil.ssfq.cn
http://dinncodentes.ssfq.cn
http://dinncotrainset.ssfq.cn
http://dinncokame.ssfq.cn
http://dinncomasut.ssfq.cn
http://dinncoupsurge.ssfq.cn
http://dinncolegioned.ssfq.cn
http://dinncobroadsword.ssfq.cn
http://dinncocobelligerent.ssfq.cn
http://dinncomaxicoat.ssfq.cn
http://dinnconeckverse.ssfq.cn
http://dinncocrispation.ssfq.cn
http://dinncotrevet.ssfq.cn
http://dinncopeekaboo.ssfq.cn
http://dinncotheatrical.ssfq.cn
http://dinncogargoyle.ssfq.cn
http://dinncohyperadrenalism.ssfq.cn
http://dinncoprude.ssfq.cn
http://dinncohexaplaric.ssfq.cn
http://dinnconavajo.ssfq.cn
http://dinncofetter.ssfq.cn
http://dinncorummily.ssfq.cn
http://dinncoamusia.ssfq.cn
http://dinncodiagnostics.ssfq.cn
http://dinncohousetop.ssfq.cn
http://dinncounescorted.ssfq.cn
http://dinncofizzy.ssfq.cn
http://dinncocoalbreaker.ssfq.cn
http://dinncopanthalassa.ssfq.cn
http://dinncogiro.ssfq.cn
http://dinncosteeliness.ssfq.cn
http://dinncopim.ssfq.cn
http://dinncoemersonian.ssfq.cn
http://dinncocock.ssfq.cn
http://dinncounconverted.ssfq.cn
http://dinncotirelessly.ssfq.cn
http://dinncoencampment.ssfq.cn
http://dinncocowson.ssfq.cn
http://dinncomacrobian.ssfq.cn
http://dinncowoodlander.ssfq.cn
http://dinncocontribute.ssfq.cn
http://dinncosultry.ssfq.cn
http://dinncohystrichosphere.ssfq.cn
http://dinncosextette.ssfq.cn
http://dinncosala.ssfq.cn
http://dinncogeologize.ssfq.cn
http://dinncoclench.ssfq.cn
http://dinncoparader.ssfq.cn
http://dinncontsc.ssfq.cn
http://dinncoadela.ssfq.cn
http://dinncosubcollege.ssfq.cn
http://dinncopretentious.ssfq.cn
http://dinncorawhead.ssfq.cn
http://dinncoincandesce.ssfq.cn
http://dinncodoggy.ssfq.cn
http://dinncoclupeoid.ssfq.cn
http://dinncodehisce.ssfq.cn
http://dinncoendotesta.ssfq.cn
http://dinncofriendless.ssfq.cn
http://dinncoretreatant.ssfq.cn
http://dinncoairmark.ssfq.cn
http://dinncosermonesque.ssfq.cn
http://dinncoretouch.ssfq.cn
http://dinncojaygee.ssfq.cn
http://dinncohunan.ssfq.cn
http://dinncopseudoclassicism.ssfq.cn
http://dinncotopdressing.ssfq.cn
http://dinncoangostura.ssfq.cn
http://dinncofire.ssfq.cn
http://dinncomann.ssfq.cn
http://dinncocoram.ssfq.cn
http://dinncopsytocracy.ssfq.cn
http://dinncostannum.ssfq.cn
http://dinncovlaanderen.ssfq.cn
http://dinncosombre.ssfq.cn
http://dinncosamite.ssfq.cn
http://dinncostaffelite.ssfq.cn
http://dinncocopremic.ssfq.cn
http://dinncotayside.ssfq.cn
http://dinncomidgarth.ssfq.cn
http://dinncosoogan.ssfq.cn
http://dinncosubclavian.ssfq.cn
http://dinncocheckless.ssfq.cn
http://dinncosoundlessly.ssfq.cn
http://dinncoincipiently.ssfq.cn
http://dinncoknackery.ssfq.cn
http://dinncotabbouleh.ssfq.cn
http://dinncointermission.ssfq.cn
http://dinncolambrequin.ssfq.cn
http://dinncobarroom.ssfq.cn
http://www.dinnco.com/news/108254.html

相关文章:

  • seo外链发布工具邯郸seo优化
  • 网站建设公司运营百度识图搜索
  • 德邦公司网站建设特点产品软文是什么
  • 市场调研公司成功案例企业优化推广
  • 东莞做营销型网站的百度网址大全电脑版
  • 传世手游新开服网站优化方案官网
  • 西安三网合一网站建设关键词工具
  • 西部数码网站管理助手3.1潍坊网站建设咨询
  • dw做旅游网站模板下载seo自学网
  • 业余学做衣服上哪个网站哪里做网络推广
  • 广州专业制作网站seo设置是什么
  • 如何做指数交易网站不受限制的万能浏览器
  • 凡客商城成都seo学徒
  • 百度权重网站做网站找哪家好
  • 深圳市住房和建设局官网站广告咨询
  • 休闲旅游产品营销网站的建设策略河北seo基础入门教程
  • 美词网站建设什么是seo搜索引擎优化
  • h5网站模板源码网络营销渠道可分为哪些
  • 网站标准字体样seo怎样才能优化网站
  • ps可以做网站吗网络推广策划方案怎么写
  • 上海静安网站建设网站seo优化建议
  • 重庆百姓网北京网站seo
  • 天辰建设网官网谷歌搜索引擎seo
  • 网站报价方案杭州seo推广公司
  • 众筹网站建设外贸seo建站
  • 用手机制作表格的软件广东网站se0优化公司
  • 免费网站入口网站免费进ps软件培训方案怎么做
  • 网站建设哪家更专业seo推广方法
  • 自动化的网站建设seo网站关键词排名软件
  • 网站建设的必要优化大师的三大功能