Module:MOS in EDO allperiods: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Renamed functions for consistency with new module name
ArrowHead294 (talk | contribs)
mNo edit summary
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local mos = require('Module:MOS')
local mos = require("Module:MOS")
local rat = require('Module:Rational')
local rat = require("Module:Rational")
local utils = require('Module:Utils')
local utils = require("Module:Utils")
local mosinedo = require('Module:MOS in EDO')
local mosinedo = require("Module:MOS in EDO")
local yesno = require("Module:Yesno")
local p = {}
local p = {}


Line 11: Line 12:
function p.parse_entries(unparsed)
function p.parse_entries(unparsed)
local parsed = {}
local parsed = {}
for entry in string.gmatch(unparsed, '([^;]+)') do
for entry in string.gmatch(unparsed, "([^;]+)") do
local trimmed = entry:gsub("^%s*(.-)%s*$", "%1")
local trimmed = entry:gsub("^%s*(.-)%s*$", "%1")
table.insert(parsed, trimmed) -- Add to array
table.insert(parsed, trimmed) -- Add to array
Line 26: Line 27:
local generation_limit = generation_limit or edo - 1
local generation_limit = generation_limit or edo - 1
local temperaments = temperaments
local temperaments = temperaments
is_debug = (is_debug or false)
-- Include temperament names?
-- Include temperament names?
Line 60: Line 63:
-- TODO: Show period/note/subset limits if applicable
-- TODO: Show period/note/subset limits if applicable
local result = ""
local result = ""
result = result .. string.format("This page lists all [[moment of symmetry]] scales in [[%iedo]].\n", edo)
result = result .. string.format("This page lists all [[moment of symmetry]] scales in [[%iedo]].\n__TOC__\n", edo)
-- Call a for loop that produces a set of tables for each period count
-- Call a for loop that produces a set of tables for each period count
Line 81: Line 84:
-- Add a section header
-- Add a section header
if number_of_periods == 1 then
if number_of_periods == 1 then
result = result .. string.format("== Single-period MOS scales ==\n")
result = result .. "<h2>Single-period MOS scales</h2>\n"
else
else
-- If the L2 header wasn't written yet, write that, followed by
-- If the L2 header wasn't written yet, write that, followed by
Line 87: Line 90:
-- header.
-- header.
if not multi_period_header_written then
if not multi_period_header_written then
result = result .. string.format("== Multi-period MOS scales ==\n")
result = result .. string.format("<h2>Multi-period MOS scales</h2>\n")
result = result .. string.format("=== %i periods ===\n", number_of_periods)
multi_period_header_written = true
multi_period_header_written = true
else
result = result .. string.format("=== %i periods ===\n", number_of_periods)
end
end
result = result .. string.format("<h3>%i periods</h3>\n", number_of_periods)
end
end
Line 117: Line 118:
result = result .. mosinedo.mos_in_edo_simplified(edo, i, number_of_periods, generation_limit)
result = result .. mosinedo.mos_in_edo_simplified(edo, i, number_of_periods, generation_limit)
end
end
result = result .. "\n\n"
end
end
end
end
Line 122: Line 124:
end
end
-- Add categories
result = result .. string.format("[[Category:%iedo]]\n", edo)
.. "[[Category:Lists of scales]]\n"
.. "[[Category:MOS scales]]"
return result
return result
end
end


function p.test()
function p.test()
return tonumber("")
return tonumber("")
end
end
Line 141: Line 147:
-- Maximum values can be overridden to have no max if set to "-1"
-- Maximum values can be overridden to have no max if set to "-1"
function p.mos_in_edo_allperiods_frame(frame)
function p.mos_in_edo_allperiods_frame(frame)
local edo = tonumber(frame.args["EDO"])
local edo = tonumber(frame.args["EDO"])
local temperaments = p.parse_entries(frame.args["Temperaments"])
local temperaments = p.parse_entries(frame.args["Temperaments"])
Line 147: Line 152:
local max_periods = tonumber(frame.args["Period Limit"]) or -1
local max_periods = tonumber(frame.args["Period Limit"]) or -1
local generation_limit = tonumber(frame.args["Generation Limit"]) or -1
local generation_limit = tonumber(frame.args["Generation Limit"]) or -1
local debugg = yesno(frame.args["debug"])
local result = p.mos_in_edo_allperiods(edo, max_periods, show_subsets, generation_limit, temperaments)
local result = ""
-- Debugger option
result = p.mos_in_edo_allperiods(edo, max_periods, show_subsets, generation_limit, temperaments)
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
return result
end
return frame:preprocess(result)
end
end


return p
return p