Module:Set to list: Difference between revisions
Appearance
Content deleted Content added
HouseBlaster (talk | contribs) create meta-module |
HouseBlaster (talk | contribs) better |
||
Line 1: | Line 1: | ||
local p = {} |
|||
-- Converts a set (table with values as true) to a list (array of keys) |
-- Converts a set (table with values as true) to a list (array of keys) |
||
function |
return function (set) |
||
local list = {} |
local list = {} |
||
for key, value in pairs(set) do |
for key, value in pairs(set) do |
||
Line 12: | Line 10: | ||
return list |
return list |
||
end |
end |
||
return p |
Revision as of 00:22, 29 May 2025
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This is a meta-module, designed to convert a "set" table (keys where the values are set to true) into a list. It does not work if called from a regular template.
Syntax
require('Module:Set to list').setToList( { a = true , b = true , c = true } )
returns
{ a , b , c }