Module:Prime limit navigation
Jump to navigation
Jump to search
Documentation transcluded from /doc
Generates the navigation bar for prime limit pages.
Do not use this module directly, use the template instead: Template:Prime limit navigation.
Documentation transcluded from /doc
local p = {}
local PRIME_LIST = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
local function table_index (t, v)
for i, ti in ipairs (t) do
if v == ti then
return i
end
end
return nil
end
function p.prime_limit_navigation (frame)
local i = table_index (PRIME_LIST, tonumber (frame.args['limit']))
local entry_prev, entry_curr, entry_next = "", "", ""
if PRIME_LIST[i] then
entry_curr = "[[" .. PRIME_LIST[i] .. "-limit]]"
if PRIME_LIST[i-1] then
entry_prev = "<small>[[" .. PRIME_LIST[i-1] .. "-limit|← " .. PRIME_LIST[i-1] .. "-limit]]</small> "
else
entry_prev = ""
end
if PRIME_LIST[i+1] then
entry_next = " <small>[[" .. PRIME_LIST[i+1] .. "-limit|" .. PRIME_LIST[i+1] .. "-limit →]]</small>"
else
entry_next = ""
end
end
return "<div class=\"toccolours\" style=\"float: right\">\n" ..
"<center>'''[[Prime limit]]'''</center>\n" ..
"----\n" ..
entry_prev .. entry_curr .. entry_next .. "\n" ..
"</div>"
end
return p;