中文乐谱库
未登录
登录
搜索
导航
首页
最近更改
随机页面
乐谱
作曲家
所有乐谱
乐器/流派
国籍
时期
编辑
编辑作曲家
编辑乐谱
关于
捐助/支持
关于我们
成为贡献者
常见问题
工具
链入页面
相关更改
特殊页面
页面信息
页面历史
刷新页面
←
模块:首页2
查看“模块:首页2”的源代码
名字空间
模块
讨论
视图
查看
查看源代码
历史
操作
来自中文乐谱库
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
local z = {} -- from [[模块:Random]] local function randomizeArray(t, limit) -- Randomizes an array. It works by iterating through the list backwards, each time swapping the entry -- "i" with a random entry. Courtesy of Xinhuan at http://forums.wowace.com/showthread.php?p=279756 -- If the limit parameter is set, the array is shortened to that many elements after being randomized. -- The lowest possible value is 0, and the highest possible is the length of the array. local len = #t for i = len, 2, -1 do local r = math.random(i) t[i], t[r] = t[r], t[i] end if limit and limit < len then local ret = {} for i, v in ipairs(t) do if i > limit then break end ret[i] = v end return ret else return t end end function getItems( frame ) local page = mw.title.new( frame.args.title ):getContent() local matches = {} local black = {} if frame.args.black then for b in mw.text.gsplit( frame.args.black, '|', true ) do black[b] = true end end for m in mw.ustring.gmatch ( page, frame.args.pattern ) do if not black[m] then table.insert ( matches, m ) end end return matches end function z.count( frame ) return #getItems( frame ) end function z.list( frame ) local d = getItems( frame ) math.randomseed(mw.site.stats.edits + mw.site.stats.pages + os.time() + math.floor(os.clock() * 1000000000)) local limit = 3 if frame.args.limit and tonumber(frame.args.limit) >1 then limit = tonumber(frame.args.limit) end l = randomizeArray(d, limit) x = table.concat(l, "]]-[[") x = '[['.. x.. ']]' return x end return z
该页面使用的模板:
模块:首页2/doc
(
查看源代码
)
返回至
模块:首页2
。