Anonymous

Module:FunList/Test: Difference between revisions

From Melvor Idle
no edit summary
(Created page with "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 } },...")
 
No edit summary
 
Line 42: Line 42:
     local enum = TableIterator.new(tbl)
     local enum = TableIterator.new(tbl)
      
      
     local result = enum
     local result = TableIterator.new(mainTable)
         :map(function (x) return 'Result: ' .. x end)
         :where(function(x) return x.id % 2 ~= 0 end)
        :zip({1,2,3})
         :flatMap(function(x) return x.details end)
         :flatMap(function(x) return x end)
         :where(function(x) return tonumber(x) ~= nil end)
         :toDictionary(function(key, i) return key end, function(v, i) return i end)
        :sum()
          
          
     Debug.log(result)
     Debug.log(result)
2,875

edits