跳转到内容

模組:首页2/sandbox

维基百科,自由的百科全书

这是本页的一个历史版本,由Shizhao留言 | 贡献2019年5月14日 (二) 07:28编辑。这可能和当前版本存在着巨大的差异。

local z = {}
local r = require('模块:Random')
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( os.time() )
	l = r.randomizeArray(d, 3)
	x = table.concat(l, ",")
return x
end

return z