Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
20
Task/Nested-templated-data/Pluto/nested-templated-data.pluto
Normal file
20
Task/Nested-templated-data/Pluto/nested-templated-data.pluto
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require "map"
|
||||
local fmt = require "fmt" -- v1.0.1 or higher
|
||||
|
||||
local function with_payload(template, payload, used)
|
||||
return template:mapped( |item| -> do
|
||||
if type(item) == "table" then
|
||||
return with_payload(item, payload, used)
|
||||
else
|
||||
used:insert(item)
|
||||
return $"'{payload[item + 1]}'"
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local p = {"Payload#0", "Payload#1", "Payload#2", "Payload#3", "Payload#4", "Payload#5", "Payload#6"}
|
||||
local t = {{{1, 2}, {3, 4, 1}, 5}}
|
||||
local used = {}
|
||||
fmt.lprint(with_payload(t, p, used))
|
||||
local unused = set.of(range(0, 6):unpack()):except(set.of(used:unpack()))
|
||||
fmt.print("\nThe unused payloads have indices of %s.", unused)
|
||||
Loading…
Add table
Add a link
Reference in a new issue