Is it possible to run a loop inside a loop in order to concatenate different levels of the same data structure?
*Note: After concatenation, the objects must still behave as objects, meaning that when hovered on they display the Preview modal. (In one partial solution, I achieved concatenation, but lost object status because concatenation converted it to text.)
Hey @Ander, not sure if this is the solution you’re looking for since it’s not exactly an array of arrays, but it gives you the ability to hover over the different levels of the arrays using the FormulaMap() function:
The formula in “desired” is:
I had to fiddle a bit longer to get a solution that will work in the project’s surrounding context (not visible in the screenshots), but I think I got it. Posted below for others who might be interested.
The trailing comma happens because you are using the Concatenate function. You could also use the Join function which joins a list of items by a provided value (see formula page here).
The formula error is a usability issue with how we treat CurrentValue. Is the formula returning your desired result?
It removes the trailing commas, but kills the object status of the list items being joined, I assume because join() converts them to text.
Anyway, the trailing commas are fine for the time being. And yes, the formula is returning the desired result, so it’s good to know that formula error is just a usability issue. Thanks for this follow-up.
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
…
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?