Module:Uniform map: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
local utils = require("Module:Utils")
local utils = require("Module:Utils")
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")
local p = {}


-- stylua: ignore
-- stylua: ignore
Line 87: Line 88:
-- Generate table of p-limit uniform maps between min and max, for use with print_table
-- Generate table of p-limit uniform maps between min and max, for use with print_table
-- Could potentially be used standalone for raw data with headers
-- Could potentially be used standalone for raw data with headers
function p.make_table(prime, min, max)
function p.make_table(prime, prec, min, max)
local maptable = {} -- Table of uniform maps with boundaries and wart notation
local maptable = {} -- Table of uniform maps with boundaries and wart notation
local map_table = p.new()
local map_table = p.new()
Line 99: Line 100:
table.insert(maptable, row)
table.insert(maptable, row)
while lb < max do
while lb < max do
row = { string.format("%.4f", lb), string.format("%.4f", ub), p.wart(map_table.map) }
row = { string.format(string.format("%%.%df", tonumber(prec)), lb), string.format(string.format("%%.%df", tonumber(prec)), ub), p.wart(map_table.map) }
for j = 1, #map_table.map do
for j = 1, #map_table.map do
table.insert(row, map_table.map[j])
table.insert(row, map_table.map[j])
Line 118: Line 119:
local max = args["max"]
local max = args["max"]
local edo = args["edo"]
local edo = args["edo"]
local prec = args["prec"]
local debugg = yesno(args["debug"])
local debugg = yesno(args["debug"])


Line 137: Line 139:
end
end


local luatable = p.make_table(prime, min, max)
local luatable = p.make_table(prime, prec, min, max)
local wtable = '{| class="wikitable"\n'
local result = '{| class="wikitable"\n'
.. '|+ style="font-size: 105%; | '
.. '|+ style="font-size: 105%; | '
.. string.format("%d-limit [[uniform map]]s between %g and %g\n", prime, min, max)
.. string.format("%d-limit [[uniform map]]s between %g and %g\n", prime, min, max)
.. "|-\n"
.. "|-\n"
for i = 1, 3 do
for i = 1, 3 do
wtable = wtable .. "! " .. luatable[1][i] .. "\n"
result = result .. "! " .. luatable[1][i] .. "\n"
end
end
wtable = wtable .. "! Map\n"
result = result .. "! Map\n"
for i = 2, #luatable do
for i = 2, #luatable do
wtable = wtable .. "|-\n"
result = result .. "|-\n"
for j = 1, 3 do
for j = 1, 3 do
wtable = wtable .. "| " .. luatable[i][j] .. "\n"
result = result .. "| " .. luatable[i][j] .. "\n"
end
end
local wikimap = ""
local wikimap = ""
Line 155: Line 157:
wikimap = wikimap .. " " .. luatable[i][j]
wikimap = wikimap .. " " .. luatable[i][j]
end
end
wtable = wtable .. string.format("| {{map|%s}}\n", wikimap)
result = result .. string.format("| {{map|%s}}\n", wikimap)
end
end
wtable = wtable .. "|}"
result = result .. "|}"


return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. wtable .. "</syntaxhighlight>" or wtable)
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


return p
return p