I have a very large ragged list result that is a list of list of pairs where sometimes the sub-list contains the empty list.
res = {{{20, 1}, {200, 2}}, {{}}, {{175, 1}}};
In the above minimal example there are 3 list with 2 containing list of pairs and one the empty list. The actual list is much longer with longer sub-list.
I need to place a value from RandomVariate
as the third entry in each pair. However, to keep performance reasonable, I only want to call RandomVariate
once for the total number of values I need. In this case I would call it for 3 values.
If the 3 values returned are
vals = {a, b, c};
Then is it possible to efficiently produce
{{{20, 1, a}, {200, 2, b}}, {{}}, {{175, 1, c}}}
without loops/procedural programming? For context the actual list will hold around 100,000+ sub-list each with zero to five pairs.