function mminsert(tbl, key, value)
if tbl[key] == nil then tbl[key] = {} end
table.insert(tbl[key], value)
end
function mmcontains(tbl, key, value)
if tbl[key] ~= nil then
for _, v in ipairs(tbl[key]) do
if v == value then return true end
end
end
return false
endtest run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #389 |
| Snippet name: | mminsert / mmcontains (multimap functions) |
| Eternal ID of this version: | #389/1 |
| Text MD5: | 783c117c561a8361c5c6bee660586c7c |
| Author: | stefan |
| Category: | table functions |
| Type: | Lua code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-03-11 18:22:09 |
| Source code size: | 300 bytes / 13 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 927 / 249 |
| Referenced in: | [show references] |