Vicífhoclóir gawiktionary https://ga.wiktionary.org/wiki/Pr%C3%ADomhleathanach MediaWiki 1.47.0-wmf.8 case-sensitive Meán Speisialta Plé Úsáideoir Plé úsáideora Vicífhoclóir Plé Vicífhoclóra Íomhá Plé íomhá MediaWiki Plé MediaWiki Teimpléad Plé teimpléid Cabhair Plé cabhrach Catagóir Plé catagóire Aguisín Plé aguisín TimedText TimedText talk Module Module talk Event Event talk baile 0 4865 59017 58446 2026-06-24T12:59:17Z Altronic 10608 Cóipeáil na tras-scríbhinn AIF ón Wictionary as Béarla 59017 wikitext text/x-wiki {{Vicipéid|Baile}} {{t|ga}} {{-fuaim-}} * AIF ([[Mumhain]]): {{IPA|/ˈbˠalʲə/}} * AIF ([[Connachta]]): {{IPA|/ˈbˠalʲə/}}, ([[Cois Fharraige]]) {{IPA|[ˈbˠaːlʲə]}}, {{IPA|/ˈbˠælʲə/}} * AIF ([[Ulaidh]]): {{IPA|/ˈbˠælʲə/}} ~ {{IPA|/ˈbˠɛlʲə/}} ~ {{IPA|/ˈbˠelʲə/}} {{-sanas-}} Ón {{s-t|Sean-Ghaeilge}} {{s-f|baile}}. {{-ainm-|ga}} {{ainm 4|f|bailte|bailte}} # [[pobal|Pobal]] daoine idir cúpla [[céad]] duine agus cúpla [[míle]]. # Áit ina gcónaíonn daoine. {{-aistr-}} {{(|Pobal|C}} {{aistr|cy|tref}} {{bain}} {{aistr|br|kêr}} {{aistr|kw|}} {{-|C}} {{aistr|gd|baile}} {{aistr|gv|}} {{--}} {{aistr|eu|herri}} {{aistr|en|town}} {{aistr|ca|ciutat}} {{bain}} {{aistr|da|by}} {{aistr|eo|urbo}} {{aistr|fi|pikkupaukunki}} {{aistr|fr|ville}} {{bain}} {{aistr|gl|cidade}} {{bain}} {{aistr|de|Stadt}} {{bain}} {{aistr|it|città}} {{bain}} {{-}} {{aistr|is|bær}} {{fir}} {{aistr|nl|stad}} {{bain}} {{aistr|la|oppidum}} {{n}} {{aistr|lt|miestelis}} {{fir}} {{aistr|oc|ciutat}} {{bain}} {{aistr|pl|miasto}} {{n}} {{aistr|pt|cidade}} {{bain}} {{aistr|ro|oraș}} {{aistr|es|ciudad}} {{bain}}, {{aistr2|es|pueblo}} {{fir}} {{aistr|sv|stad}} {{c}} {{)}} {{(|Áit chónaithe|C}} {{aistr|cy|cartref}} {{fir}} {{aistr|br|kêr}} {{aistr|kw|}} {{-|C}} {{aistr|gd|taigh}} {{aistr|gv|}} {{--}} {{aistr|eu|etxe}} {{aistr|en|home}} {{aistr|ca|casa}} {{bain}} {{aistr|da|by}} {{aistr|eo|urbo}} {{aistr|fi|pikkupaukunki}} {{aistr|fr|maison}} {{bain}} {{aistr|gl|casa}} {{bain}} {{aistr|de|Haus}} {{n}}, {{aistr|de|Wohnung}} {{bain}} {{aistr|it|casa}} {{bain}} {{-}} {{aistr|is|heimili}} {{n}} {{aistr|nl|huis}} {{fir}} {{aistr|la|domus}} {{bain}} {{aistr|lt|namas}} {{fir}} {{aistr|oc|}} {{aistr|pl|dom}} {{fir}} {{aistr|pt|casa}} {{bain}} {{aistr|ro|casă}} {{bain}} {{aistr|es|casa}} {{bain}}, {{aistr2|es|hogar}} {{fir}} {{aistr|sv|hem}} {{n}} {{)}} {{t|gd}} {{-fuaim-}} * AIF: {{IPA|/ˈpalə/}} {{-sanas-}} Ón {{s-t|Sean-Ghaeilge}} {{s-f|baile}}. {{-ainm-|gd}} {{pn}} {{fir}} (''gu.'' '''[[baile]]''', ''iol.'' '''[[bailtean]]''') # {{ucf|baile}}. {{-tag-}} 1negwz04vja4r8v6wwf634nt37t5td8 59018 59017 2026-06-24T13:11:38Z Altronic 10608 Cuir cuid na Sean-Ghaeilge leis 59018 wikitext text/x-wiki {{Vicipéid|Baile}} {{t|ga}} {{-fuaim-}} * AIF ([[Mumhain]]): {{IPA|/ˈbˠalʲə/}} * AIF ([[Connachta]]): {{IPA|/ˈbˠalʲə/}}, ([[Cois Fharraige]]) {{IPA|[ˈbˠaːlʲə]}}, {{IPA|/ˈbˠælʲə/}} * AIF ([[Ulaidh]]): {{IPA|/ˈbˠælʲə/}} ~ {{IPA|/ˈbˠɛlʲə/}} ~ {{IPA|/ˈbˠelʲə/}} {{-sanas-}} Ón {{s-t|Sean-Ghaeilge}} {{s-f|baile}}. {{-ainm-|ga}} {{ainm 4|f|bailte|bailte}} # [[pobal|Pobal]] daoine idir cúpla [[céad]] duine agus cúpla [[míle]]. # Áit ina gcónaíonn daoine. {{-aistr-}} {{(|Pobal|C}} {{aistr|cy|tref}} {{bain}} {{aistr|br|kêr}} {{aistr|kw|}} {{-|C}} {{aistr|gd|baile}} {{aistr|gv|}} {{--}} {{aistr|eu|herri}} {{aistr|en|town}} {{aistr|ca|ciutat}} {{bain}} {{aistr|da|by}} {{aistr|eo|urbo}} {{aistr|fi|pikkupaukunki}} {{aistr|fr|ville}} {{bain}} {{aistr|gl|cidade}} {{bain}} {{aistr|de|Stadt}} {{bain}} {{aistr|it|città}} {{bain}} {{-}} {{aistr|is|bær}} {{fir}} {{aistr|nl|stad}} {{bain}} {{aistr|la|oppidum}} {{n}} {{aistr|lt|miestelis}} {{fir}} {{aistr|oc|ciutat}} {{bain}} {{aistr|pl|miasto}} {{n}} {{aistr|pt|cidade}} {{bain}} {{aistr|ro|oraș}} {{aistr|es|ciudad}} {{bain}}, {{aistr2|es|pueblo}} {{fir}} {{aistr|sv|stad}} {{c}} {{)}} {{(|Áit chónaithe|C}} {{aistr|cy|cartref}} {{fir}} {{aistr|br|kêr}} {{aistr|kw|}} {{-|C}} {{aistr|gd|taigh}} {{aistr|gv|}} {{--}} {{aistr|eu|etxe}} {{aistr|en|home}} {{aistr|ca|casa}} {{bain}} {{aistr|da|by}} {{aistr|eo|urbo}} {{aistr|fi|pikkupaukunki}} {{aistr|fr|maison}} {{bain}} {{aistr|gl|casa}} {{bain}} {{aistr|de|Haus}} {{n}}, {{aistr|de|Wohnung}} {{bain}} {{aistr|it|casa}} {{bain}} {{-}} {{aistr|is|heimili}} {{n}} {{aistr|nl|huis}} {{fir}} {{aistr|la|domus}} {{bain}} {{aistr|lt|namas}} {{fir}} {{aistr|oc|}} {{aistr|pl|dom}} {{fir}} {{aistr|pt|casa}} {{bain}} {{aistr|ro|casă}} {{bain}} {{aistr|es|casa}} {{bain}}, {{aistr2|es|hogar}} {{fir}} {{aistr|sv|hem}} {{n}} {{)}} {{t|gd}} {{-fuaim-}} * AIF: {{IPA|/ˈpalə/}} {{-sanas-}} Ón {{s-t|Sean-Ghaeilge}} {{s-f|baile}}. {{-ainm-|gd}} {{pn}} {{fir}} (''gu.'' '''[[baile]]''', ''iol.'' '''[[bailtean]]''') # {{ucf|baile}}. {{-tag-}} {{t|sga}} {{-fuaim-}} * AIF: {{IPA|/ˈba.lʲe/}} {{-ainm-|sga}} # [[baile]], [[cathair]] (áit ina gcónaíonn duine) owl2s7oisaslkee7ocgvged23hgvi2m Úsáideoir:Altronic 2 9269 59019 2026-06-25T11:43:41Z Altronic 10608 Leathanach cruthaithe le '{{Babel|en|ga-2|gd-2|jp-2}} Adding lua modules and templates from the English Wiktionary.' 59019 wikitext text/x-wiki {{Babel|en|ga-2|gd-2|jp-2}} Adding lua modules and templates from the English Wiktionary. 6sog1jm5zwkaef79hapwu6dv1e4e6cn Module:debug 828 9270 59020 2026-06-25T11:45:20Z Altronic 10608 Copy over module from English Wiktionary 59020 Scribunto text/plain local export = {} local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local byte = string.byte local concat = table.concat local escape -- defined below local format = string.format local gsub = string.gsub local insert = table.insert local match = string.match local sub = string.sub local toNFC = mw.ustring.toNFC local function is_array(...) is_array = require(table_module).isArray return is_array(...) end local function isutf8(...) isutf8 = require(string_utilities_module).isutf8 return isutf8(...) end local function sorted_pairs(...) sorted_pairs = require(table_module).sortedPairs return sorted_pairs(...) end local function table_size(...) table_size = require(table_module).size return table_size(...) end do local escapes local function get_escapes() escapes, get_escapes = { ["\a"] = [[\a]], ["\b"] = [[\b]], ["\t"] = [[\t]], ["\n"] = [[\n]], ["\v"] = [[\v]], ["\f"] = [[\f]], ["\r"] = [[\r]], ["\""] = [[\"]], ["'"] = [[\']], ["\\"] = [[\\]], }, nil return escapes end local function escape_byte(ch) return (escapes or get_escapes())[ch] or format("\\%03d", byte(ch)) end local function escape_bytes(ch) return (gsub(ch, ".", escape_byte)) end local function escape_char(ch) local ch_len = #ch if ch_len == 1 then return escape_byte(ch) end local b = byte(ch) -- Matching bytes below \128 are all to be escaped, \128 to \191 can't -- be leading bytes in UTF-8, \192 and \193 could only occur in overlong -- encodings, so can't occur in UTF-8, U+0080 (\194\128) to U+009F -- (\194\159) are control characters, U+00A0 (\194\160) is the no-break -- space, and \245 to \255 could only occur in encodings for codepoints -- above U+10FFFF, so can't occur in UTF-8. if b < 194 or b > 244 or (b == 194 and byte(ch, 2) < 161) then return escape_bytes(ch) -- 2-byte encodings starting \194 to \223 are all valid, so no need to -- check them with isutf8(). If there are additional trailing -- bytes, escape them. elseif b < 224 then return ch_len == 2 and ch or (sub(ch, 1, 2) .. escape_bytes(sub(ch, 3))) end -- Check 3- and 4-byte encodings with isutf8(), as they might be -- invalid due to overlong encodings or being above U+10FFFF. As above, -- escape any additional trailing bytes. local n = b < 240 and 3 or 4 if ch_len == n then return isutf8(ch) and ch or escape_bytes(ch) elseif ch_len > n then local init_ch = sub(ch, 1, n) if isutf8(init_ch) then return init_ch .. escape_bytes(sub(ch, n + 1)) end end return escape_bytes(ch) end local function escape_non_NFC(str) local normalized = toNFC(str) if normalized == str then return str end local str_len, i, start, offset, output = #str, 1, 1, 0 while i <= str_len do local b = byte(str, i) if b == byte(normalized, i + offset) then i = i + 1 else if output == nil then output = {} end -- Backtrack to the start of the character. while b >= 128 and b < 192 do i = i - 1 b = byte(str, i) end -- Insert any intermediate characters up to this point. if start ~= i then insert(output, sub(str, start, i - 1)) end -- Get the first character, then find the sequence of characters -- which differs from the normalized string. local seq = match(str, "^.[\128-\191]*", i) -- Find the raw sequence and the normalized sequence by adding -- a character at a time to the raw sequence, and checking if -- it matches the current point in the normalized string. -- This is necessary to ensure that the offset between the two -- strings is correct, when comparing equivalent sections. local seq_len, poss_seq, norm_seq = #seq, seq while true do if not norm_seq then norm_seq = match(normalized, "^" .. toNFC(poss_seq), i + offset) -- Once a matching sequence has been found, check if it's -- still possible to match the same normalized sequence with -- a longer raw sequence, as form NFC will have taken the -- longest sequence when normalizing the input. elseif toNFC(poss_seq) ~= norm_seq then break end seq, seq_len = poss_seq, #poss_seq local nxt_ch = match(str, "^.[\128-\191]*", i + seq_len) if nxt_ch == nil then break end poss_seq = poss_seq .. nxt_ch end -- Modify the offset to account for the difference in length -- between the two sequences. Usually, the NFC form will be -- shorter, but in rare cases it is longer (e.g. U+0F73 -- normalizes to U+0F71 + U+0F72). offset = offset + #norm_seq - seq_len i = i + seq_len start = i -- Escape the non-ASCII portion of the sequence. This ensures -- that escapes added by escape_char don't end up double-escaped -- if they would otherwise be modified by form NFC; e.g. "\n" + -- U+0303 ("\ñ") needs to avoid escaping the "n". if seq ~= "" then insert(output, (gsub(seq, "[\128-\255]", escape_byte))) end end end if output == nil then return str end insert(output, sub(str, start)) return concat(output) end -- Escapes control characters, backslash, double quote, the no-break space, -- bytes that aren't used in UTF-8, invalid UTF-8 character sequences, and -- any bytes necessary to ensure that the output is Unicode form NFC, -- because MediaWiki automatically converts page content to form NFC; e.g. -- "e" + U+0301 ("é") results in "e\204\129", because otherwise the sequence -- would be converted to "é" (U+00E9)); this ensures that results can be -- relied upon to be stable if saved as part of page content. function export.escape(str) return escape_non_NFC(gsub(str, "[%c\"'\\\128-\255][\128-\191]*", escape_char)) end escape = export.escape end -- Convert a value to a string function export.dump(value, prefix, tsort) local t = type(value) prefix = prefix or "" if t == "string" then return '"' .. escape(value) .. '"' elseif t == "table" then local str_table = {} insert(str_table, " {") for key, val in sorted_pairs(value, tsort) do insert(str_table, " " .. prefix .. "\t[" .. export.dump(key, prefix .. "\t") .. "] = " .. gsub(export.dump(val, prefix .. "\t"), "^ ", "") .. ",") end insert(str_table, " " .. prefix .. "}") return concat(str_table, "\n") else return tostring(value) end end function export.highlight_dump(value, prefix, tsort, options) options = options or {} local func = options.modified and "modified_dump" or "dump" local dump = export[func](value, prefix, tsort) -- Remove spaces at beginnings of lines (which are simply to force a <pre></pre> tag). dump = gsub(dump, "%f[^%z\n] ", "") return export.highlight(dump) end -- Returns true if table contains a table as one of its values local function containsTable(t) for _, value in pairs(t) do if type(value) == "table" then return true end end return false end local function containsTablesWithSize(t, size) for _, value in pairs(t) do if type(value) == "table" and table_size(value) ~= size then return false end end return true end --[=[ Convert a value to a string. Like dump below, but if a table has consecutive numbered keys and does not have a table as one of its values, it will be placed on a single line. Used by [[Module:User:Erutuon/script recognition]]. ]=] function export.modified_dump(value, prefix, tsort) local t = type(value) prefix = prefix or "" if t == "string" then return '"' .. value .. '"' elseif t == "table" then local str_table = {} local containsTable = containsTable(value) local consecutive = is_array(value) if consecutive and not containsTable or containsTable and containsTablesWithSize(value, 3) then insert(str_table, "{") for key, val in sorted_pairs(value, tsort) do if containsTable then insert(str_table, "\n\t" .. prefix) else insert(str_table, " ") end if type(key) == "string" then insert(str_table, "[" .. export.modified_dump(key) .. "] = ") end insert(str_table, type(key) == "number" and type(val) == "number" and format("0x%05X", val) or export.modified_dump(val)) if not (consecutive and #value == 3) or type(key) == "number" and value[key + 1] then insert(str_table, ",") end end if containsTable then insert(str_table, "\n" .. prefix) else insert(str_table, " ") end insert(str_table, "}") return concat(str_table) end insert(str_table, " {") for key, val in sorted_pairs(value, tsort) do insert(str_table, " " .. prefix .. "\t[" .. export.modified_dump(key, prefix .. "\t") .. "] = " .. gsub(export.modified_dump(val, prefix .. "\t"), "^ ", "") .. ",") end insert(str_table, " " .. prefix .. "}") return concat(str_table, "\n") elseif t == "number" and value > 46 then return format("0x%05X", value) else return tostring(value) end end export.track = require("Module:debug/track") -- Trigger a script error from a template function export.error(frame) error(frame.args[1] or "(no message specified)") end --[[ Convenience function for generating syntaxhighlight tags. Display defaults to block. Options is a table. To display inline text with HTML highlighting: { inline = true, lang = "html" } ]] function export.highlight(content, options) if type(content) == "table" then options = content options = { lang = options.lang or "lua", inline = options.inline and true } return function(content) return mw.getCurrentFrame():extensionTag("syntaxhighlight", content, options) end else return mw.getCurrentFrame():extensionTag("syntaxhighlight", content, { lang = options and options.lang or "lua", inline = options and options.inline and true or nil }) end end function export.track_unrecognized_args(args, template_name) local function track(code) export.track(template_name .. "/" .. code) end track("unrecognized arg") local arg_list = {} for arg, value in pairs(args) do track("unrecognized arg/" .. arg) insert(arg_list, format("|%s=%s", arg, value)) end mw.log(format("Unrecognized parameter%s in {{%s}}: %s.", arg_list[2] and "s" or "", template_name, concat(arg_list, ", ") )) end do local placeholder = "_message_" function export._placeholder_error(frame) -- A dummy function that throws an error with a placeholder message. error(placeholder, (frame.args.level or 1) + 6) end -- Throw an error via callParserFunction, which generates a real error with traceback, automatic categorization in [[CAT:E]] etc., but the error message is returned as a string. Then, replace the placeholder error message with `message`, which is preprocessed. This is necessary when preprocessing needs to be applied (e.g. when using <pre> tags), since otherwise strip markers and other half-processed text gets displayed instead. function export.formatted_error(message, level) local frame = mw.getCurrentFrame() return (frame:callParserFunction("#invoke", {"debug", "_placeholder_error", level = level}) :gsub(placeholder, frame:preprocess(message))) end end return export flmvh7jakbzodr3hhecvopt1m6pdzph Module:table 828 9271 59021 2026-06-25T11:58:49Z Altronic 10608 Copy over module from English Wiktionary 59021 Scribunto text/plain local export = {} --[==[ intro: This module provides functions for dealing with Lua tables. All of them, except for two helper functions, take a table as their first argument. Some functions are available as methods in the arrays created by [[Module:array]]. Functions by what they do: * Create a new table: ** `shallowCopy`, `deepCopy`, `removeDuplicates`, `numKeys`, `compressSparseArray`, `keysToList`, `reverse`, `invert`, `listToSet` * Create an array: ** `removeDuplicates`, `numKeys`, `compressSparseArray`, `keysToList`, `reverse` * Return information about the table: ** `size`, `length`, `contains`, `isArray`, `deepEquals` * Treat the table as an array (that is, operate on the values in the array portion of the table: values indexed by consecutive integers starting at {1}): ** `removeDuplicates`, `length`, `contains`, `serialCommaJoin`, `reverseIpairs`, `reverse`, `invert`, `listToSet`, `isArray` * Treat a table as a sparse array (that is, operate on values indexed by non-consecutive integers): ** `numKeys`, `maxIndex`, `compressSparseArray`, `sparseConcat`, `sparseIpairs` * Generate an iterator: ** `sparseIpairs`, `sortedPairs`, `reverseIpairs` * Other functions: ** `sparseConcat`, `serialCommaJoin`, `reverseConcat` The original version was a copy of {{w|Module:TableTools}} on Wikipedia via [[c:Module:TableTools|Module:TableTools]] on Commons, but in the course of time this module has been almost completely rewritten, with many new functions added. The main legacy of this is the use of camelCase for function names rather than snake_case, as is normal in the English Wiktionary. ]==] local load_module = "Module:load" local math_module = "Module:math" local table = table local concat = table.concat local dump = mw.dumpObject local ipairs = ipairs local ipairs_default_iter = ipairs{export} local next = next local pairs = pairs local require = require local select = select local signed_index -- defined as export.signedIndex local table_len -- defined as export.length local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function is_integer(...) is_integer = require(math_module).is_integer return is_integer(...) end local function safe_require(...) safe_require = require(load_module).safe_require return safe_require(...) end --[==[ Given an array and a signed index, returns the true table index. If the signed index is negative, the array will be counted from the end, where {-1} is the highest index in the array; otherwise, the returned index will be the same. To aid optimization, the first argument may be a number representing the array length instead of the array itself; this is useful when the array length is already known, as it avoids recalculating it each time this function is called.]==] function export.signedIndex(t, k) if not is_integer(k) then error("index must be an integer") end return k < 0 and (type(t) == "table" and table_len(t) or t) + k + 1 or k end signed_index = export.signedIndex --[==[ An iterator which works like `pairs`, but ignores any `__pairs` metamethod.]==] function export.rawPairs(t) return next, t, nil end --[==[ An iterator which works like `ipairs`, but ignores any `__ipairs` metamethod.]==] function export.rawIpairs(t) return ipairs_default_iter, t, 0 end --[==[ This returns the length of a table, or the first integer key n counting from 1 such that t[n + 1] is nil. It is a more reliable form of the operator `#`, which can become unpredictable under certain circumstances due to the implementation of tables under the hood in Lua, and therefore should not be used when dealing with arbitrary tables. `#` also does not use metamethods, so will return the wrong value in cases where it is desirable to take these into account (e.g. data loaded via `mw.loadData`). If `raw` is set, then metamethods will be ignored, giving the true table length. For arrays, this function is faster than `export.size`.]==] function export.length(t, raw) local n = 0 if raw then for i in ipairs_default_iter, t, 0 do n = i end return n end repeat n = n + 1 until t[n] == nil return n - 1 end table_len = export.length local function getIteratorValues(i, j , step, t_len) i, j = i and signed_index(t_len, i), j and signed_index(t_len, j) if step == nil then i, j = i or 1, j or t_len return i, j, j < i and -1 or 1 elseif step == 0 or not is_integer(step) then error("step must be a non-zero integer") elseif step < 0 then return i or t_len, j or 1, step end return i or 1, j or t_len, step end --[==[ Given an array `list` and function `func`, iterate through the array applying {func(r, k, v)}, and returning the result, where `r` is the value calculated so far, `k` is an index, and `v` is the value at index `k`. For example, {reduce(array, function(a, _, v) return a + v end)} will return the sum of `array`. Optional arguments: * `i`: start index; negative values count from the end of the array * `j`: end index; negative values count from the end of the array * `step`: step increment These must be non-zero integers. The function will determine where to iterate from, whether to iterate forwards or backwards and by how much, based on these inputs (see examples below for default behaviours). Examples: # No values for i, j or step results in forward iteration from the start to the end in steps of 1 (the default). # step=-1 results in backward iteration from the end to the start in steps of 1. # i=7, j=3 results in backward iteration from indices 7 to 3 in steps of 1 (i.e. step=-1). # j=-3 results in forward iteration from the start to the 3rd last index. # j=-3, step=-1 results in backward iteration from the end to the 3rd last index.]==] function export.reduce(t, func, i, j, step) i, j, step = getIteratorValues(i, j, step, table_len(t)) local ret = t[i] for k = i + step, j, step do ret = func(ret, k, t[k]) end return ret end do local function replace(t, func, i, j, step, generate) local t_len = table_len(t) -- Normalized i, j and step, based on the inputs. local norm_i, norm_j, norm_step = getIteratorValues(i, j, step, t_len) if norm_step > 0 then i, j, step = 1, t_len, 1 else i, j, step = t_len, 1, -1 end -- "Signed" variables are multiplied by -1 if `step` is negative. local t_new, signed_i, signed_j = generate and {} or t, norm_i * step, norm_j * step for k = i, j, step do -- Replace the values iff they're within the i to j range and `step` wouldn't skip the key. -- Note: i > j if `step` is positive; i < j if `step` is negative. Otherwise, the range is empty. local signed_k = k * step if signed_k >= signed_i and signed_k <= signed_j and (k - norm_i) % norm_step == 0 then t_new[k] = func(k, t[k]) -- Otherwise, add the existing value if `generate` is set. elseif generate then t_new[k] = t[k] end end return t_new end --[==[ Given an array `list` and function `func`, iterate through the array applying {func(k, v)} (where `k` is an index, and `v` is the value at index `k`), replacing the relevant values with the result. For example, {apply(array, function(_, v) return 2 * v end)} will double each member of the array. Optional arguments: * `i`: start index; negative values count from the end of the array * `j`: end index; negative values count from the end of the array * `step`: step increment These must be non-zero integers. The function will determine where to iterate from, whether to iterate forwards or backwards and by how much, based on these inputs (see examples below for default behaviours). Examples: # No values for i, j or step results in forward iteration from the start to the end in steps of 1 (the default). # step=-1 results in backward iteration from the end to the start in steps of 1. # i=7, j=3 results in backward iteration from indices 7 to 3 in steps of 1 (i.e. step=-1). # j=-3 results in forward iteration from the start to the 3rd last index. # j=-3, step=-1 results in backward iteration from the end to the 3rd last index.]==] function export.apply(t, func, i, j, step) return replace(t, func, i, j, step, false) end --[==[ Given an array `list` and function `func`, iterate through the array applying {func(k, v)} (where `k` is an index, and `v` is the value at index `k`), and return a shallow copy of the original array with the relevant values replaced. For example, {generate(array, function(_, v) return 2 * v end)} will return a new array in which each value has been doubled. Optional arguments: * `i`: start index; negative values count from the end of the array * `j`: end index; negative values count from the end of the array * `step`: step increment These must be non-zero integers. The function will determine where to iterate from, whether to iterate forwards or backwards and by how much, based on these inputs (see examples below for default behaviours). Examples: # No values for i, j or step results in forward iteration from the start to the end in steps of 1 (the default). # step=-1 results in backward iteration from the end to the start in steps of 1. # i=7, j=3 results in backward iteration from indices 7 to 3 in steps of 1 (i.e. step=-1). # j=-3 results in forward iteration from the start to the 3rd last index. # j=-3, step=-1 results in backward iteration from the end to the 3rd last index.]==] function export.generate(t, func, i, j, step) return replace(t, func, i, j, step, true) end end --[==[ Given an array `list` and function `func`, iterate through the array applying {func(k, v)} (where `k` is an index, and `v` is the value at index `k`), and returning whether the function is true for all iterations. Optional arguments: * `i`: start index; negative values count from the end of the array * `j`: end index; negative values count from the end of the array * `step`: step increment These must be non-zero integers. The function will determine where to iterate from, whether to iterate forwards or backwards and by how much, based on these inputs (see examples below for default behaviours). Examples: # No values for i, j or step results in forward iteration from the start to the end in steps of 1 (the default). # step=-1 results in backward iteration from the end to the start in steps of 1. # i=7, j=3 results in backward iteration from indices 7 to 3 in steps of 1 (i.e. step=-1). # j=-3 results in forward iteration from the start to the 3rd last index. # j=-3, step=-1 results in backward iteration from the end to the 3rd last index.]==] function export.all(t, func, i, j, step) i, j, step = getIteratorValues(i, j, step, table_len(t)) for k = i, j, step do if not func(k, t[k]) then return false end end return true end --[==[ Given an array `list` and function `func`, iterate through the array applying {func(k, v)} (where `k` is an index, and `v` is the value at index `k`), and returning whether the function is true for at least one iteration. Optional arguments: * `i`: start index; negative values count from the end of the array * `j`: end index; negative values count from the end of the array * `step`: step increment These must be non-zero integers. The function will determine where to iterate from, whether to iterate forwards or backwards and by how much, based on these inputs (see examples below for default behaviours). Examples: # No values for i, j or step results in forward iteration from the start to the end in steps of 1 (the default). # step=-1 results in backward iteration from the end to the start in steps of 1. # i=7, j=3 results in backward iteration from indices 7 to 3 in steps of 1 (i.e. step=-1). # j=-3 results in forward iteration from the start to the 3rd last index. # j=-3, step=-1 results in backward iteration from the end to the 3rd last index.]==] function export.any(t, func, i, j, step) i, j, step = getIteratorValues(i, j, step, table_len(t)) for k = i, j, step do if not not (func(k, t[k])) then return true end end return false end --[==[ Joins an array with serial comma and serial conjunction, normally {"and"}. An improvement on {mw.text.listToText}, which doesn't properly handle serial commas. Options: * `conj`: Conjunction to use; defaults to {"and"}. * `punc`: Punctuation to use; default to {","}. * `dontTag`: Don't tag the serial comma and serial {"and"}. For error messages, in which HTML cannot be used. * `dump`: Each item will be serialized with {mw.dumpObject}. For warnings and error messages.]==] function export.serialCommaJoin(seq, options) -- If the `dump` option is set, determine the table length as part of the -- dump loop, instead of calling `table_len` separately. local length if options and options.dump then local i, item = 1, seq[1] if item ~= nil then local dumped = {} repeat dumped[i] = dump(item) i = i + 1 item = seq[i] until item == nil seq = dumped end length = i - 1 else length = table_len(seq) end if length == 0 then return "" elseif length == 1 then return seq[1] end local conj = options and options.conj if conj == nil then conj = "and" end if length == 2 then return seq[1] .. " " .. conj .. " " .. seq[2] end local punc, dont_tag if options then punc = options.punc if punc == nil then punc = "," end dont_tag = options.dontTag else punc = "," end local comma if dont_tag then comma = "" -- since by default the serial comma doesn't display, when we can't tag we shouldn't display it. conj = " " .. conj .. " " else comma = "<span class=\"serial-comma\">" .. punc .. "</span>" conj = "<span class=\"serial-and\"> " .. conj .. "</span> " end return concat(seq, punc .. " ", 1, length - 1) .. comma .. conj .. seq[length] end --[==[ A function which works like `table.concat`, but respects any `__index` metamethod. This is useful for data loaded via `mw.loadData`.]==] function export.concat(t, sep, i, j) local list, k = {}, 0 while true do k = k + 1 local v = t[k] if v == nil then return concat(list, sep, i, j) end list[k] = v end end --[==[ Add a list of aliases for a given key to a table. The aliases must be given as a table.]==] function export.alias(t, k, aliases) for _, alias in pairs(aliases) do t[alias] = t[k] end end local mt = {} function mt:__index(k) local submodule = safe_require("Module:table/" .. k) self[k] = submodule return submodule end return setmetatable(export, mt) exw27st65r96fvgc4krew9cy4eyvdow