Module:FunList/Test
Documentation for this module may be created at Module:FunList/Test/doc
local p = {}
local Debug = require('Module:Debug')
local TableIterator = require('Module:FunList/Sandbox')
local mainTable = {
[1] = {
id = 1,
name = "Item One",
details = {
description = "This is the first item.",
price = 10.99
}
},
[2] = {
id = 2,
name = "Item Two",
details = {
description = "This is the second item.",
price = 20.49
}
},
[3] = {
id = 3,
name = "Item Three",
details = {
description = "This is the third item.",
price = 15.75
}
}
}
function p.test()
local tbl = {}
for i = 1, 10 do
tbl[i] = string.char(96 + i) -- 96 is the ASCII value for 'a' minus 1
end
--tbl['#'] = '##'
table.insert(tbl, 'a')
table.insert(tbl, 'd')
table.insert(tbl, 'f')
local enum = TableIterator.new(tbl)
local result = enum
:map(function (x) return 'Result: ' .. x end)
:zip({1,2,3})
:flatMap(function(x) return x end)
:toDictionary(function(key, i) return key end, function(v, i) return i end)
Debug.log(result)
Debug.log('@@end@@')
end
return p