Module:ED intro: Difference between revisions
Tristanbay (talk | contribs) also removed the function thingy Tag: Manual revert |
Address Template talk: ED intro #Square/cube root of 2. Now square/cube root are displayed instead of 2nd/3rd root |
||
| Line 38: | Line 38: | ||
local edstep_size_rounded = utils._round(edstep_size, 3) | local edstep_size_rounded = utils._round(edstep_size, 3) | ||
local is_exact = edstep_size - edstep_size_rounded == 0 | local is_exact = edstep_size - edstep_size_rounded == 0 | ||
local intro_text = "" | local intro_text = "" | ||
| Line 52: | Line 50: | ||
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | ||
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | ||
intro_text = string.gsub(intro_text, "''kth''", | intro_text = string.gsub(intro_text, "''kth''", p.root_ordinal(ed)) | ||
return intro_text | return intro_text | ||
| Line 66: | Line 64: | ||
local edstep_size_rounded = utils._round(edstep_size, 3) | local edstep_size_rounded = utils._round(edstep_size, 3) | ||
local is_exact = edstep_size - edstep_size_rounded == 0 | local is_exact = edstep_size - edstep_size_rounded == 0 | ||
local intro_text = "" | local intro_text = "" | ||
| Line 80: | Line 76: | ||
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | ||
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | ||
intro_text = string.gsub(intro_text, "''kth''", | intro_text = string.gsub(intro_text, "''kth''", p.root_ordinal(ed)) | ||
return intro_text | return intro_text | ||
| Line 94: | Line 90: | ||
local edstep_size_rounded = utils._round(edstep_size, 3) | local edstep_size_rounded = utils._round(edstep_size, 3) | ||
local is_exact = edstep_size - edstep_size_rounded == 0 | local is_exact = edstep_size - edstep_size_rounded == 0 | ||
local intro_text = "" | local intro_text = "" | ||
| Line 108: | Line 102: | ||
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | ||
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | ||
intro_text = string.gsub(intro_text, "''kth''", | intro_text = string.gsub(intro_text, "''kth''", p.root_ordinal(ed)) | ||
return intro_text | return intro_text | ||
| Line 123: | Line 117: | ||
local edstep_size_rounded = utils._round(edstep_size, 3) | local edstep_size_rounded = utils._round(edstep_size, 3) | ||
local is_exact = edstep_size - edstep_size_rounded == 0 | local is_exact = edstep_size - edstep_size_rounded == 0 | ||
local intro_text = "" | local intro_text = "" | ||
| Line 137: | Line 129: | ||
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | ||
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | ||
intro_text = string.gsub(intro_text, "''kth''", | intro_text = string.gsub(intro_text, "''kth''", p.root_ordinal(ed)) | ||
intro_text = string.gsub(intro_text, "hth", ord._ordinal(harmonic)) | intro_text = string.gsub(intro_text, "hth", ord._ordinal(harmonic)) | ||
intro_text = string.gsub(intro_text, "''h''", harmonic) | intro_text = string.gsub(intro_text, "''h''", harmonic) | ||
| Line 154: | Line 146: | ||
local edstep_size_rounded = utils._round(edstep_size, 3) | local edstep_size_rounded = utils._round(edstep_size, 3) | ||
local is_exact = edstep_size - edstep_size_rounded == 0 | local is_exact = edstep_size - edstep_size_rounded == 0 | ||
local intro_text = "" | local intro_text = "" | ||
| Line 168: | Line 158: | ||
intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | intro_text = string.gsub(intro_text, "exactly/about", (is_exact and "exactly" or "about")) | ||
intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | intro_text = string.gsub(intro_text, "''s''", utils._round (edstep_size, 3)) | ||
intro_text = string.gsub(intro_text, "''kth''", | intro_text = string.gsub(intro_text, "''kth''", p.root_ordinal(ed)) | ||
intro_text = string.gsub(intro_text, "''p/q''", rat.as_ratio(ratio)) | intro_text = string.gsub(intro_text, "''p/q''", rat.as_ratio(ratio)) | ||
| Line 183: | Line 173: | ||
local edstep_size_rounded = utils._round(edstep_size, 3) | local edstep_size_rounded = utils._round(edstep_size, 3) | ||
local is_exact = edstep_size - edstep_size_rounded == 0 | local is_exact = edstep_size - edstep_size_rounded == 0 | ||
local intro_text = "" | local intro_text = "" | ||
| Line 200: | Line 188: | ||
return intro_text | return intro_text | ||
end | |||
-- ord._ordinal but for roots | |||
function p.root_ordinal(n) | |||
local result = ord._ordinal(n) | |||
if n == 2 then | |||
result = "square" | |||
elseif n == 3 then | |||
result = "cube" | |||
end | |||
return result | |||
end | end | ||