Maintain outer scope in two for loops?

Trying to do something trivial to do with two for loops but surprisingly incredibly hard to do with coda.

Say I have two values, Ps (say p1…p5) and Bs (say b1…b10)
I have one table here I want a selection to allow users to choose among values, in csv form that would ultimately look like:
P1, B1, B5, B10
P2, B2, B3, B10

image

What I need is to then have a view that creates a row for each pair chosen. That is, in csv that would look like:
P1, B1
P1, B5
P1, B10
P2, B2

etc.

Essentially what I need is something like this pseudocode:
for each row r1 in Assignments:
for each b in r1.Bs:
AddRow(Pairs, Pairs.P, r1.p, Pairs.B, b)

I’ve tried many combinations of FormulaMap and Sequnece but the fundamental problem seems like any looping construct losses the scope of the parent loop. That is, if I tried to have a FormulaMap within a FormulaMap “CurrentValue” only has the inner scope. Another thing I tried is to first add all the Ps and then add all the Bs in a different formula but I run into the same issue. Don’t really see how coda can claim to be turing complete. Any ideas?

Here’s the trick you’re looking for:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.