I'm trying to figure out how to nest/chain an object comprehension to do something other than a 'full product' and have the inner loop iterate a different amount, but can't figure it out.
{ ["%s-thing-%i" % [grp.name, n]]: { name: grp.name, // a bunch of other stuff I don't want to repeat } // for n in std.range(1, grp.count) // invalid, 'Unknown variable: grp' for n in std.range(1, 3) for grp in [{name: "foo", count: 2}, {name: "bar", count: 4}]}
I want a one-level object with two foo-thing-
s and four bar-thing-
s, but I can't use the count
object property like on my commented line as at that point grp
is not defined.