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") | ||
-- 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("%. | 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 | 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 | ||
result = result .. "! " .. luatable[1][i] .. "\n" | |||
end | end | ||
result = result .. "! Map\n" | |||
for i = 2, #luatable do | for i = 2, #luatable do | ||
result = result .. "|-\n" | |||
for j = 1, 3 do | for j = 1, 3 do | ||
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 | ||
result = result .. string.format("| {{map|%s}}\n", wikimap) | |||
end | end | ||
result = result .. "|}" | |||
-- Debugger option | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p |